Problem:
 Score : 300 points    Problem Statement Snuke has a fair N -sided die that shows the integers from 1 to N with equal probability and a fair coin. He will play the following game with them:   Throw the die. The current score is the result of the die.  As long as the score is between 1 and K-1 (inclusive), keep flipping the coin. The score is doubled each time the coin lands heads up, and the score becomes 0 if the coin lands tails up.  The game ends when the score becomes 0 or becomes K or above. Snuke wins if the score is K or above, and loses if the score is 0 .   You are given N and K . Find the probability that Snuke wins the game.      Constraints  1 ≤ N ≤ 10^5  1 ≤ K ≤ 10^5  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  K       Output Print the probability that Snuke wins the game. The output is considered correct when the absolute or relative error is at most 10^{-9} .        Sample Input 1 3 10      Sample Output 1 0.145833333333   If the die shows 1 , Snuke needs to get four consecutive heads from four coin flips to obtain a score of 10 or above. The probability of this happening is \frac{1}{3} \times (\frac{1}{2})^4 = \frac{1}{48} .  If the die shows 2 , Snuke needs to get three consecutive heads from three coin flips to obtain a score of 10 or above. The probability of this happening is \frac{1}{3} \times (\frac{1}{2})^3 = \frac{1}{24} .  If the die shows 3 , Snuke needs to get two consecutive heads from two coin flips to obtain a score of 10 or above. The probability of this happening is \frac{1}{3} \times (\frac{1}{2})^2 = \frac{1}{12} .   Thus, the probability that Snuke wins is \frac{1}{48} + \frac{1}{24} + \frac{1}{12} = \frac{7}{48} \simeq 0.1458333333 .       Sample Input 2 100000 5      Sample Output 2 0.999973749998

Solution (Python):
N, K = map(int, input().split())
ans = 0
for i in range(1, N+1):
    a = i
    c = 0
    while a < K:
        a = a * 2
        c = c + 1
    ans = ans + (1/2)**c/N
print(ans)

Solution (Python):
N, K = map(int, input().split())

score = N
counter_tmp = 0
ans = 0


for i in range(N):
    counter_tmp = 0
    score = i + 1
    while score < K:
        score = score * 2
        counter_tmp += 1
    ans += 1 / (N * (2 ** counter_tmp))

print(ans)

Solution (Python):
from math import log2, ceil

N,K = map(int,input().split())

ans = 0

def cal(n):
    l = ceil(log2(K/n))
    if n >= K:
        return 1/N
    return pow(2,-l)/N

for i in range(1,N+1):
    ans += cal(i)

print(ans)

Solution (Python):
import math

n, k = map(int, input().split())

p = 0
for i in range(1, n+1):
    m = max(math.ceil(math.log(k/i, 2)), 0)
    pi = (1/n) * (1/(2**m))
    p += pi

print(p)

Solution (Python):
n, k = map(int, input().split())
ans = 0
for i in range(1, n + 1):
    w = 1
    tmp = i
    while tmp < k:
        tmp *= 2
        w *= 0.5
    ans += w
print(ans / n)

Solution (Python):
N,K = map(int,input().split())

def f(X):
    ans = 0
    while (2**ans)*X < K:
        ans += 1
    return ans

b = 0.0
for i in range(1,N+1):
    b += 1/(2**f(i))

print("{:.10}".format(b/N))

Solution (Python):
n, k = (int(_) for _ in input().split())
ans = 0


for i in range(1, n+1):
    score = i
    power = 0
    while score < k:
        score = score*2
        power += 1
    ans += 1/n * 0.5**power
    
print(ans)

Solution (Python):
from math import ceil

N,K = map(int, input().split())

ans = 0
for i in range(1, N+1):
    t = 1
    while i*t < K:
        t *= 2
    ans += 1/t
print(ans/N)

Solution (Python):
N, K = [int(i) for i in input().split()]
ratio = 0
for i in range( 1, N+1):
    score = i
    p = 1/N
    while score < K:
        score *= 2
        p /= 2
    ratio += p
print(ratio)

Solution (Python):
from collections import deque
from heapq import heappush,heappop
import re

def int_raw():
    return int(input())

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int, ss_raw()))

INF = 1<<29

N,K =  ints_raw()
def main():
    ans = 0
    buf = 0
    for n in range(N,0,-1):
        tmp  =n*(2**buf)
        if tmp< K:
            while tmp < K:
                tmp *=2
                buf+=1
        ans += (0.5)**(buf)
    return ans/N

print(main())

Solution (Python):
import math
a=list(map(int,input().split()))
total=0
K=a[1]
if a[0]>=a[1]:
    tmp=a[1]
    total+=a[0]-a[1]+1
else:
    tmp=a[0]+1
    
for i in range(1,tmp):
    hoge=K/i
    total+=1/pow(2,math.ceil(math.log(hoge,2)))
print(total/a[0])

Solution (Python):
import math

n, k = map(int, input().split())
sum_p = 0
for first_score in range(1,n+1):
    if first_score >= k:
        sum_p += 1/n
        continue
    sum_p += (1/n )*((1/2)**math.ceil(math.log2(k/first_score)))
print(sum_p)

Solution (Python):
import math

n,k=map(int,input().split())
ans=0
cnt=0
a=n
while n>0:
    if n>=k:
        ans+=(n-k+1)/a*(1/2)**cnt
        n=k-1
    k=math.ceil(k/2)
    cnt+=1
    
print(ans)

Solution (Python):
import numpy as np
import math

def main():
    N, K = map(int, input().split())
    prob = 0
    for i in range(1, N + 1):
        score = i
        if (score >= K):
            left = N - score + 1
            prob += left / N
            break
        else:
            num = 1
            while(True):
                if (score * 2 < K):
                    num += 1
                    score *= 2
                else:
                    prob += 1/(N * (2)**num)
                    break
    print(prob)


if __name__ == '__main__':
    main()

Solution (Python):
import math

def main():
    N, K = [int(n) for n in input().split()]
    needed = (math.log2(K))

    nex = 2
    res = 0
    for i in range(1, N+1):
        if i >= K:
            res += 1
            continue
        res += math.pow(0.5, math.ceil(needed-math.log2(i)))
        
    res /= N * 1.
    print(res)
main()

Solution (Python):
import numpy as np
import math

n, k = map(int, input().split())
ans = 0

for i in range(1, n+1):
    if i >= k:
        ans += 1
    else:
        success = math.ceil(np.log2(k/i))
        ans += 0.5 ** success
    
print(ans/n)

Solution (Python):
import math

n, k = map(int, input().split())

cnt = 0

for i in range(n):
    if i >= k:
        cnt += 1 / n
    else:
        cnt += 1 / n  / (2 ** math.ceil(math.log2(k / (i + 1))))
    
print(cnt)

Solution (Python):
import sys
N, K = map(int, input().split())

ans = 0
for i in range(1,N+1):
    j = 0
    while i * (2**j) < K:
        j += 1
    ans += (1/2)**j
print (ans/N)

Solution (Python):
import math
n,k=map(int,input().split())
ans=0
for i in range(1,n+1):
    if i<k:
        
        times=math.ceil(math.log2(k/i))
        ans+=math.pow(0.5,times)
    else:
        ans+=1
print(ans/n)

Solution (Python):
import math

N, K = map(int, input().split())

ans = 0
for i in range(1, N + 1):
    if i < K:
        x = math.log2(K / i)
        x = 0.5**math.ceil(x)
    else:
        x = 1
    ans += x / N
print(ans)

Solution (Python):
n, k = map(int, input().split())
result = 0
for i in range(1, n + 1):
    point = i
    count = 0
    while point < k :
        point = point * 2
        count += 1
    result += (1/n) * ((1/2) ** count)
print(result)

Solution (Python):
N, K = [int(i) for i in input().strip().split(" ")]

a = 0
for i in range(N):
  p = i + 1
  j = 0
  while p < K:
    p = p * 2
    j = j + 1

  a = a + (1 / N * 0.5 ** j)

print(a)

Solution (Python):
import math

N, K = (int(i) for i in input().split())
possibility = 0
for i in range(1, N+1):
    if i < K:
        possibility += 1/N * ((1/2)**math.ceil(math.log2(K/i)))
    else:
        possibility += 1/N
print(possibility)

Solution (Python):
N, K = map(int, input().split())
ans = 0
for i in range(1, N+1):
    if i >= K:
        ans += (1 / N)
        continue
    t = 1.0
    for j in range(1, K):
        t /= 2
        if i * 2 ** j >= K: break
    ans += (t / N)
print(ans)

Solution (Python):


N,K = list(map(int,input().split()))
rate = 0
for i in range (N):
    count = 0
    init_num = i+1
    while init_num < K:
        init_num *= 2
        count += 1
    rate += (0.5 ** count)/N
        
print (rate)

Solution (Python):
import math
n,k = [int(u) for u in input().split(" ")]
h = [
  math.ceil(math.log2(k/u)) if u<k else 0
  for u in range(1,n+1)
]
s = sum([1/pow(2,u) for u in h])
print(s/n)

Solution (Python):
import math

N,K = (int(i) for i in input().split())
roots = []
hoge = K
result = 0

while hoge != 1:
    roots.append(hoge)
    hoge = math.ceil(hoge/2)

roots.append(1)

for i in range(len(roots)):
    if N >= roots[i]:
        result += (N - roots[i] + 1) / 2 ** i
        onon = i
        break

while onon < len(roots) - 1:
    result += (roots[onon] - roots [onon + 1]) / 2 ** (onon + 1)
    onon += 1

result = result / N
print(result)

Solution (Python):
N,K=(int(x) for x in input().split())
ans=0
for n in range(N):
    me=n+1
    if me>=K:
        ans=ans+(1/N)
    else:
        for j in range(20):
            me=me*2
            if me>=K:
                ji=2**(j+1)
                ans=ans+(1/N)*(1/ji)
                break
print(ans)

Solution (Python):

"""
C - Dice and Coin
https://atcoder.jp/contests/abc126/tasks/abc126_c

"""
import sys


from decimal import *
from math import log2, ceil


def __solve(N, K):
    getcontext().prec = 30
    ans = Decimal(0)
    for i in range(1, N+1):
        if i >= K:
            t = Decimal (1/N)
        else:
            t = Decimal(1/N/2**ceil(log2(K/i)))
        ans += t
    return ans


def solve(N, K):
    ans = 0
    for i in range(1, N+1):
        if i >= K:
            t = 1 / N
        else:
            t = 1/N/2**ceil(log2(K/i))
        ans += t
    return ans


def main(args):
    N, K = map(int, input().split())
    ans = solve(N, K)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):
N, K = list(map(int, input().split()))

ans = 0

for score in range(1, N + 1):
    a = 1.0 / N
    while True:
        if score >= K:
            ans += a
            break
        else:
            a *= 0.5
            score = score << 1

print(ans)

Solution (Python):
n,k=map(int,input().split())
import math
ans=0
for i in range(1,n+1):
    if i<k:
        res=math.ceil(math.log2(k/i))
        ans+=(1/n)*0.5**res
    else:
        ans+=(n-i+1)/n
        break
print(ans)

Solution (Python):

N, K = map(int, input().split())

p = 0

for i in range(1, N + 1):
    point = i
    temp_p = 1/N
    while point < K:
        point = 2 * point
        temp_p = temp_p * 1/2

    p = p + temp_p


print(p)

Solution (Python):
import numpy as np
N, K = map(int, input().split())
ans = []
for i in range(N):
	pt = i + 1
	p = 1.
	while pt <= K - 1:
		pt = 2 * pt
		p = p / 2.
	ans.append(p)
ans1 = np.sum(ans) * 1. / N
print(ans1)

Solution (Python):
import math

N,K = (int(i) for i in input().split())
roots = []
hoge = K
result = 0

while hoge != 1:
    roots.append(hoge)
    hoge = math.ceil(hoge/2)

roots.append(1)

for i in range(len(roots)):
    if N >= roots[i]:
        result += (N - roots[i] + 1) / 2 ** i
        onon = i
        break

while onon < len(roots) - 1:
    result += (roots[onon] - roots [onon + 1]) / 2 ** (onon + 1)
    onon += 1

result = result / N
print(result)

Solution (Python):
N,K = map(int,input().split())
def solve1(dice,K):
    i = 0
    while dice < K :
        dice = dice * 2
        i += 1
    return i
ans = 0
for p in range(1,N+1,1):
    ans += (1/N)*(1/2)**solve1(p,K)
print(ans)

Solution (Python):
import math
log2 = math.log2
ceil = math.ceil
read = input
n,k = map(int, read().split())
ans = 0.0
for i in range(1, n+1):
    if i >= k:
        ans += 1
    else :
        ans += 0.5 ** ceil(log2(k/i))
ans /= n
print('%.12f'%ans)

Solution (Python):
import numpy as np
n,k=map(int, input().split())  

arr = np.arange(1,n+1)
arr_x = np.ceil(np.log2(k) - np.log2(arr))
arr_x[np.where(arr_x <= 0)] = 0
prob = ((1/n) * (0.5 ** arr_x)).sum()

print(prob)

Solution (Python):
a,b=input().split()
a=int(a)
b=int(b)
x=0.5
count=0
for i in range(1,a+1):
    dcount=0
    while 1:
        if i>=b:
            break
        i=i*2
        dcount+=1
    if dcount==0:
        count+=1/a
    else:
        count+=1/a*x**dcount
print(count)

Solution (Python):
N,K = map(int,input().split())

ans = 0

for i in range(1,N+1) :
    pr = 1/N
    
    score = i
    
    while score <= K-1 :
        pr *= (1/2)
        score *= 2
    ans += pr
print(ans)

Solution (Python):
import sys
from math import ceil, log2
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
N, K = tuple(li())
total = 0
for i in range(1, N + 1):
    if i < K:
        total += 2 ** -ceil(log2(K/i))
    else:
        total += 1
print(total/N)

Solution (Python):
N,K=map(int,input().split())
P=0
for i in range(N):
  temp_i=i+1
  temp_P=1/N
  while(temp_i<K):
    temp_i*=2
    temp_P*=1/2
  P+=temp_P
print(P)

Solution (Python):
import bisect

l = [1 for i in range(31)]


for i in range(1, 31):
    l[i] = l[i - 1] * 2

N, K = map(int, input().split())
P = 0.0
for i in range(1, N + 1):
    times = bisect.bisect_left(l, K/i)
    P += (1/N) * ((1/2)**times)

print(P)

Solution (Python):
import math
N, K = map(int, input().split())
p = [0 for i in range(N)]
for i in range(1,N+1):
    kaisu = max(0, math.ceil(math.log2(K/i)))
    
    p[i-1] = (1 / N) * 0.5 ** kaisu
print(sum(p))

Solution (Python):
import math

N, K = map(int, input().split())
ans = 0.0
for i in range(1, N+1):
    if i < K:
        ans += 1 / N * (0.5 ** math.ceil(math.log(K / i, 2)))
    else:
        ans += 1 / N
print(ans)

Solution (Python):

"""                         
Beautiful is better than ugly.
    Explicit is better than implicit.
Simple is better than complex.
    Complex is better than complicated.
Flat is better than nested.
    Sparse is better than dense.
                    
    * Readability counts *

 // Author : raj1307 - Raj Singh
 // Date   : 19.05.19

"""

from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().strip().split(" "))
def li(): return list(mi())

def dmain():
    sys.setrecursionlimit(100000000)
    threading.stack_size(40960000)
    thread = threading.Thread(target=main)
    thread.start()
    






abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod,MOD=1000000007,998244353
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]
def getKey(item): return item[0] 
def sort2(l):return sorted(l, key=getKey)
def d2(n,m,num):return [[num for x in range(m)] for y in range(n)]
def isPowerOfTwo (x): return (x and (not(x & (x - 1))) )
def decimalToBinary(n): return bin(n).replace("0b","")
def ntl(n):return [int(i) for i in str(n)]

def powerMod(x,y,p):
    res = 1
    x %= p
    while y > 0:
        if y&1:
            res = (res*x)%p
        y = y>>1
        x = (x*x)%p1
    return res

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x
    
def isPrime(n) : 
    if (n <= 1) : return False
    if (n <= 3) : return True
    if (n % 2 == 0 or n % 3 == 0) : return False
    i = 5
    while(i * i <= n) : 
        if (n % i == 0 or n % (i + 2) == 0) : 
            return False
        i = i + 6
    return True




  



def main():
    
    
    n,k=mi()
    prob=0
    for i in range(1,n+1):
        a=i
        c=0
        while(a<k):
            a*=2
            c+=1
        prob+=(1/n)*((1/2)**c)
        
    print(prob)
            
            
            
            
                
    
    
    
    






BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        if self.buffer.tell():
            return self.buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip(b"\r\n")



if __name__ == "__main__":
    main()

Solution (Python):
n, k = map(int, input().split())
ans = 0
for i in range(1, n + 1):
    digit_number_difference = len(str(bin(k))) - len(str(bin(i)))
    if digit_number_difference < 0:
        ans += 1/n
        continue
    elif k > i * 2 ** digit_number_difference:
        digit_number_difference += 1
    ans += (1/n) * (1/2)**digit_number_difference
print(ans)

Solution (Python):
n,k=map(int,input().split())
p=0
for i in range(n):
    count=0
    s=i+1
    while(s<k):
        s=s*2
        count+=1
    p+=1/n*(1/2)**count
print(p)

Solution (Python):
import numpy as np

N, K = map(int, input().split())

cnt_win = 0

for n in range(1, N + 1):
    if n >= K:
        cnt_win += 1
    else:
        num_front = np.ceil(np.log2(K / n))
        cnt_win += 1 / np.power(2, num_front)

print(cnt_win / N)

Solution (Python):
import numpy as np
N,K=map(int, input().split())

ans = 0
for i in range(1,N+1):
    x = np.log2((K-1)/i)
    if x < 0:
        ans += 1
    else:
        x = np.floor(x) + 1
        ans += (1/2)**x
        
ans /= N
print(ans)

Solution (Python):
N, K = map(int, input().split())

ans = 0
for i in range(N):

    sum = 0
    temp = i+1
    while temp < K:
        sum += 1
        temp *= 2

    ans += 1 / pow(2, sum) * 1/N
print(ans)

Solution (Python):
N,K = [int(item) for item in input().split()]

ans = 0
for i in range(1,N+1):
  if i < K:
    n = 0
    point = i
    while point < K:
      point *= 2
      n += 1
    ans += 1/N * (1/2)**n
  else:
    ans += 1/N
print (ans)

Solution (Python):



import sys

input = sys.stdin.readline

def main():
    n, k = [int(e) for e in input().split(" ")]
    
    
    
    
    total_p = 0.0
    for i in range(1, n+1):
        total = i
        p = 1/n
        while True:
            if total >= k:
                total_p += p
                break
            p *= 1/2
            total *= 2

    print(total_p)


main()

Solution (Python):
import math
N, K = map(int, input().split())

p = 0.0

if K <= N:
    p += (N-K+1)/N

for init_n in range(1, min([K, N+1])):
    p += 1/N * ((1/2)**math.ceil(math.log2(K/init_n)))

print(p)

Solution (Python):
import math
N, K = map(int, input().split())

p = 0
for i in range(1, N + 1):
    t = max(math.ceil(math.log2(K / i)), 0)
    p += 1 / N * (0.5) ** t
print(p)

Solution (Python):
N, K = map(int, input().split())
p = 0
l = N
i = 0
while l > 0:
  b = -(-K // (2 ** i))
  _p = max(l - b + 1, 0)
  p += _p / (N * (2 ** i))
  l -= _p
  i += 1
print(p)

Solution (Python):
n,k = map(int,input().split())
m = n
l = n
res = 0
cnt = 0
tmp = m
while m < k:
    m *= 2
    cnt += 1
res += (1/n)*(0.5)**cnt
for i in range(1,n):
    cnt = 0
    l = n
    l -= i
    cnt = 0
    while l < k:
        l *= 2
        cnt += 1
    res += (1/n)*(0.5)**cnt
print(res)

Solution (Python):

from math import floor, ceil, log2
n, k = map(int, input().split())
ans = 0
for i in range(n):
    ans += 0.5 ** ceil(max(0, log2(k / (i + 1))))
print(ans / n)

Solution (Python):
n,k = list(map(int,input().split()))

ans = float(0)

for i in range(1,n+1):
    p = float(1/n)
    if i > k:
        ans += float((n-i+1)/n)
        break
    for j in range(0,20):
        if i*(2**j) < k:
            p *= float(1/2)
    ans += p

print(ans)

Solution (Python):




import math
from fractions import Fraction

def main():
    
    n, k = [int(s) for s in input().split()]
    
    sum = Fraction(0, 1)
    for i in range(1, n+1):
        mult = math.log2(k/i)
        mult = math.ceil(mult) if mult>0 else 0
        sum += Fraction(1, 2**mult)
    sum *= Fraction(1, n)
    ans = float(sum)
    
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
N,K = map(int,input().split())
ans = 0
two = 0
for i in range(N,0,-1):
  while i*(2**two)<K:
    two+=1
  ans += (0.5)**two
print(ans/N)

Solution (Python):
N,K = map(int,input().split())
prob = 0
for i in range(N):
    point = i+1
    count = 0
    while point < K:
        point *= 2
        count += 1
    prob += 2**((-1)*count)/N
print(prob)

Solution (Python):
def calc(n,k):
	count = 0
	while n < k:
		n *= 2
		count += 1
	return count


n, k = map(int, input().split())

total = 0
basic = 1/n
for i in range(1, n+1):
	temp = basic
	if i < k:
		num = calc(i, k)
		temp *= (0.5)**num
	total += temp

print(total)

Solution (Python):
import math
N, K = map(int, input().split())
ans = 0
for i in range(1, N+1):
    
    ans += (1 / N) * 0.5 ** math.ceil(max(math.log2(K/i), 0))
print(ans)

Solution (Python):
n, k = map(int, input().split(' '))
result = 0
for i in range(1, n+1):
    c = i
    j = 0
    while c < k:
        c = c * 2
        j += 1
    result += (1/n) * (1/2)**j

print(result)

Solution (Python):


















import math
import copy
from collections import defaultdict
from collections import Counter
from collections import deque

from itertools import product

from itertools import permutations

from itertools import combinations
from bisect import bisect_left, bisect_right


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")



N, K = s_inpl()

ans = 0
for i in range(1, N+1):
    r = math.ceil(math.log2(K/i))
    if r<0:
        r = 0
    ans += (1/N) * ((0.5)**r)

print(ans)

Solution (Python):
import math

N, K = map(int, input().split())

ans = 0.0
for n in range(1, N + 1):
  i = 0
  if n < K:
    i = math.ceil(math.log2(K / n))
  ans += (0.5 ** i) / N

print("{:.15f}".format(ans))

Solution (Python):
def getlist():
	return list(map(int, input().split()))

N, K = getlist()

if K == 1:
	print(1)
else:
	ans = 0
	for i in range(1, N + 1):
		c = 0
		x = K / i
		while True:
			if x <= 1:
				break
			else:
				x = x / 2
				c += 1
		ans += (1 / 2) ** c
	print(ans / N)

Solution (Python):
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]






N, K = map(int, input().split())
ans = 0
cnt = 0

i = N
while i > 0:
    if i >= K:
        ans += pow(0.5, cnt) / N
        i -= 1
    else:
        K = (K + 1) // 2
        cnt += 1
    
print(ans)

Solution (Python):
def solve(n, k):
    list1 = []
    for i in range(1, n+1):
        cnt = 0
        while True:
            if i * 2 ** cnt >= k:
                list1 += [cnt]
                break
            cnt += 1
        
    m = max(list1)
    list2 = list(map(lambda x: m-x, list1))
    list2 = list(map(lambda x: 2**x, list2))
    return sum(list2) / (n * 2**m)

n, k = map(int, input().split())
print(solve(n, k))

Solution (Python):
import math
N, K = map(int, input().split())

def func(dice):
    if dice >= K:
        return 1.0
    return (1 / 2) ** math.ceil(math.log2(K / dice))

l = [func(dice) / N for dice in range(1, N + 1)]
print(sum(l))

Solution (Python):
import numpy as np

N, K = map(int, input().split())

times = np.zeros(N + 1, dtype=np.float)

for i in range(1, N + 1):
	if i < K:
		times[i] = np.ceil(np.log2(K / i))
	else:
		times[i] = 0


print(np.sum(0.5 ** times[1:] / N))

Solution (Python):
N, K = list(map(int,input().split()))

kakuritu = 0

for i in range(N):
    tokuten = i+1
    mokuhyou = tokuten
    cnt = 0
    while mokuhyou < K:
        mokuhyou += tokuten
        tokuten *= 2
        cnt += 1
    kakuritu += (1/N)*(1/(2**cnt))

print(kakuritu)

Solution (Python):
n, k = map(int, input().split())

ans = 0

for i in range(1, n+1):
    score = i
    need_num = 0
    while score < k:
        score *= 2
        need_num += 1
    ans += (1/n) * (1/2) ** need_num
print(ans)

Solution (Python):
N, K = map(int, input().split())
ans = 0
for i in range(1, N+1):
    tmp = 1/N
    j = 0
    while i*(2**j) < K:
        j += 1
    ans += tmp*(1/2)**j
print(ans)

Solution (Python):
n, k = map(int, input().split())

p = 0

t = 0
while 2**t < k:
    t += 1

for i in range(1, n+1):
    j = 0
    while i* 2**j < k:
        j += 1
    p += 2**(t-j)

p = p / n / 2**t

print(p)

Solution (Python):

"""
AtCoder C
"""
import math



 


 
def main():
    N, K = list(map(int,input().split()))
    
    K=float(K)

    out=0
    for n in range(1,N+1):
        
        if n>=K:
            out+=1/float(N)
        else:
            tmp=math.log2(K/n)
            
            out+=0.5**math.ceil(tmp)/float(N)
    print(out)


if __name__ == "__main__":
    main()

Solution (Python):


import math

N, K = map(int, input().split())











p = 0.0

for i in range(1, N+1):
    if K > i:
        n = math.log(K/i) / math.log(2)
        n = math.ceil(n)
        p += (1/2**n) / N
    else:
        p += 1/N

print(p)

Solution (Python):
import math
N, K =map(int,input().split())

ans = 0

for i in range(1, min(N+1,K)):
  omote = math.ceil(math.log2(K/i))
  ans = ans + (0.5**omote)/N

if(N >= K):
  ans = ans + (1- (K-1)/N)

print(ans)

Solution (Python):
n,k=map(int,input().split())
x=0
s=0
for i in range(n,0,-1):
  while i * 2 ** x < k:
    x+=1
  s+=1/(2**x)
print(s*1/n)

Solution (Python):
import math

N,K = map(int,input().split())

p = 0
for m in range(1,N+1):
  if m>=K:
    p+=1/N
  else:
  	p += 0.5**math.ceil(math.log2(K/m)) / N

print(p)

Solution (Python):
N, K = map(int, input().split())
ans = 0.0

for i in range(1, N+1):
    power = 0
    num = i
    while num < K:
        power += 1
        num *= 2
    ans += (1/N) * (0.5)**power
print(ans)

Solution (Python):

import math

def solve():
    N, K = list(map(int, input().split()))

    ans = 0
    for i in range(1, N+1):
        if i >= K:
            ans += (1/N)
            continue
        
        
        n = math.ceil(math.log2(K/i))
        ans += (1/N) * (1/2)**n

    print(ans)


if __name__ == "__main__":
    solve()

Solution (Python):
N, K = map(int, input().split())

ans = 0.0
for i in range(1, N + 1):
    count, point = 0, i
    while point < K:
        point *= 2
        count += 1
    ans += (0.5 ** count) / N

print(ans)

Solution (Python):
from math import log2,ceil,pow
N,K = map(int,input().split())
ans = 0
for n in range(1,N+1):
    num = ceil(log2(ceil(K/n)))
    rate = (1/N)*pow(1/2,num)
    ans += rate
print(ans)

Solution (Python):
from math import log2
from math import ceil

N, K = map(int, input().split())

a = list(map(ceil, [0 if (n >= K) else log2(K/n) for n in range(1, N+1)]))
a = [(1/N) * (1/2)**n for n in a]

print(sum(a))

Solution (Python):
n,k=map(int,input().split())
ans=0
for i in range(1,n+1):
    cnt=0
    sc=i
    while sc<k:
        cnt+=1
        sc*=2
    ans+=(1/n)*((1/2)**cnt)
print(ans)

Solution (Python):
import math

N, K = map(int, input().split())

prop = 0

for i in range(1, N+1):
    if i < K:
        n = math.ceil(math.log2(K/i))
    else:
        n = 0
    prop += 1/N * pow(0.5, n)

print(prop)

Solution (Python):
import math

n,k = map(int, input().split())

ans = 0
for i in range(1,n+1):
    x = max(0,math.ceil(math.log2(k/i)))
    ans += 0.5**x

print(ans/n)

Solution (Python):
N, K = map(int, input().split())

prob = 0
for n in range(1, N+1):
    i = 0
    while (2 ** i) * n < K:
        i += 1
    
    prob_a = 1.0 / float(N) * (1 / 2**i)
    
    prob += prob_a
print(prob)

Solution (Python):
N, K = map(int,input().split())
prob = 0
for i in range(N):
    j = 0
    while (i+1)*(2**j) < K:
        j += 1
    prob += 1/(N*(2**j))
print(prob)

Solution (Python):
import math

listNK = list(map(int,input().split()))
N = listNK[0]
K = listNK[1]

output = 0

for i in range(N):
    X = i+1
    if X>=K:
        output += 1/N
    else:
        n = math.log2(K/X)
        n = math.ceil(n)
        output += (1/N)*(1/2)**n

print(output)

Solution (Python):
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    import math

    n, k = map(int, input().split())

    ans = 0

    for i in range(1,n+1):
        ans += 1/(2**max(0,math.ceil(math.log2(k/i))))

    print(ans/n)

Solution (Python):

n,k = [int(i) for i in input().split()]

n0=n
i=0
kai = []
while(k!=1):
    kai.append(max(0,n-k+1))
    if n >= k:
        n = k-1
    k=(k+1)//2
kai.append(1)



ans = 0.0
for i,c in enumerate(kai):
    ans += c*2**(-i)

print(ans/n0)

Solution (Python):
import math
N,K = map(int,input().split())
Pinv = 0
for i in range(1,N+1):
  if i<K:
    Pinv += (N*2**math.ceil(math.log2(K/i)))**(-1)
  else:
    Pinv += 1/N
print(Pinv)

Solution (Python):
N, K = map(int,input().split())

sum = 0

for i in range(1, N+1):
    j = 0
    probability = 1
    score = i
    while score < K:
        
        score *= 2
        probability *= 0.5
    sum += ( probability / N )

print("{}".format(sum))

Solution (Python):
import math

N, K = map(int, input().split())

expNum = math.ceil(math.log(K, 2))

possibility_arr = []

for i in range(N):
    num = i + 1
    if num < K:
        tempNum = K/num
        expNum = math.ceil(math.log(tempNum, 2))
        poss = 1/N * 1/2**expNum
    else:
        poss = 1/N
    
    possibility_arr.append(poss)



print(sum(possibility_arr))

Solution (Python):
N, K = map(int, input().split())

ans = 0

for n in range(1, N + 1):
    p = 1 / N
    while n < K:
        p = p * (1 / 2)
        n = n * 2
    ans += p

print(ans)

Solution (Python):
import math
n, k = map(int, input().split())

def calc(dise, k):
    return (1/2) ** math.ceil(math.log2(k/dise))

ans = 0

for i in range(n):
    if i+1 >= k:
        ans += 1/n
    else:
        ans += calc(i+1, k) / n
print(ans)

Solution (Python):
n, k = list(map(int, input().split()))
result = 0
result += max((n - k + 1) , 0) / n
for i in range(1, min(k, n+1)):
    num = i
    count = 0
    while num < k:
        num *= 2
        count += 1
    result += (1/n) * ((1/2) ** count)

print(result)

Solution (Python):
import sys, os
import math

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n, k = f()
    ans = 0
    for i in range(1,n+1):
        if i<k:
            num = int(math.ceil(math.log(k/i)/math.log(2)))
            ans += 0.5**num/n
        else:
            ans += 1/n

    print(ans)

solve()

Solution (Python):
n,k = map(int, input().split())
ans = 0 
for i in range(n):
  score = i+1
  count = 0
  while score <= k-1:
    count += 1
    temp = score
    score = temp*2
  ans += 1/n * ((1/2)**count)
print(ans)