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):
import sys
from itertools import combinations, permutations, product, combinations_with_replacement, accumulate
from heapq import heapify, heappop, heappush, heappushpop
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from math import sqrt, log, floor, ceil, factorial, cos, sin, pi 
from fractions import gcd
from operator import mul
from functools import reduce
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
LINF = 2**63-1
NIL = -LINF
MOD = 10**9+7
MGN = 4
def AST(exp: bool, msg: str = ""): assert exp, msg
def TAST(exp: bool, msg = ""):
    if exp is False: print("TAssertionError:", msg)
    while exp is False:
        pass
def EPR(msg): print(msg, file=sys.stderr)
def II(): return int(input())
def IF(): return float(input())
def IS(): return input().replace('\n', '')
def ILCI(n: int): return [II() for _ in range(n)]
def ILCF(n: int): return [IF() for _ in range(n)]
def ILI(): return list(map(int, input().split()))
def ILLI(n: int): return [[int(j) for j in input().split()] for i in range(n)]
def ILF(): return list(map(float, input().split()))
def ILLF(n: int): return [[float(j) for j in input().split()] for i in range(n)]
def LTOS(lst: list, sep: str = ' '): return sep.join(map(str, lst))
def DEC(lst: list): return list(map(lambda x: x-1, lst))
def INC(lst: list): return list(map(lambda x: x+1, lst))


def main():
    N, K = ILI()

    ans = 0.0
    for i in range(1,N+1):  
        scr = i  
        pb = 1.0  
        win = True  
        while True:
            if K <= scr:  
                break
            elif 0 < scr < K:
                scr *= 2
                pb *= 0.5
            else:  
                TAST(True, "ここには来ない")
                scr = 0
                win = False
                break
        if win:
            ans += pb / N

    print("{:.12}".format(ans))


if __name__ == '__main__':
    main()

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

p = 0
for score in range(1,n+1):
    if k <= score:
        
        p += 1
    else:
        
        
        x = 1
        while(True):
            if (2**x) * score >= k:
                break
            else:
                x += 1
        p += (0.5) ** x

print(p/n)

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

Solution (Python):
import sys
from itertools import combinations, permutations, product, combinations_with_replacement, accumulate
from heapq import heapify, heappop, heappush, heappushpop
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from math import sqrt, log, floor, ceil, factorial, cos, sin, pi 
from fractions import gcd
from operator import mul
from functools import reduce
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
LINF = 2**63-1
NIL = -LINF
MOD = 10**9+7
MGN = 4
def AST(exp: bool, msg: str = ""): assert exp, msg
def TAST(exp: bool, msg = ""):
    if exp is False: print("TAssertionError:", msg)
    while exp is False:
        pass
def EPR(msg): print(msg, file=sys.stderr)
def II(): return int(input())
def IF(): return float(input())
def IS(): return input().replace('\n', '')
def ILCI(n: int): return [II() for _ in range(n)]
def ILCF(n: int): return [IF() for _ in range(n)]
def ILI(): return list(map(int, input().split()))
def ILLI(n: int): return [[int(j) for j in input().split()] for i in range(n)]
def ILF(): return list(map(float, input().split()))
def ILLF(n: int): return [[float(j) for j in input().split()] for i in range(n)]
def LTOS(lst: list, sep: str = ' '): return sep.join(map(str, lst))
def DEC(lst: list): return list(map(lambda x: x-1, lst))
def INC(lst: list): return list(map(lambda x: x+1, lst))


def main():
    N, K = ILI()

    ans = 0.0
    for i in range(1,N+1):  
        scr = i  
        pb = 1.0  
        if K <= scr:  
            ans += pb/N
            continue

        
        
        
        
        n = ceil(log(K/scr, 2))
        
        ans += pow(0.5, n) / N

    print("{:.12}".format(ans))


if __name__ == '__main__':
    main()

Solution (Python):
import sys
from itertools import combinations, permutations, product, combinations_with_replacement, accumulate
from heapq import heapify, heappop, heappush, heappushpop
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from math import sqrt, log, floor, ceil, factorial, cos, sin, pi 
from fractions import gcd
from operator import mul
from functools import reduce
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
LINF = 2**63-1
NIL = -LINF
MOD = 10**9+7
MGN = 4
def AST(exp: bool, msg: str = ""): assert exp, msg
def TAST(exp: bool, msg = ""):
    if exp is False: print("TAssertionError:", msg)
    while exp is False:
        pass
def EPR(msg = ""): print(msg, file=sys.stderr)
def II(): return int(input())
def IF(): return float(input())
def IS(): return input().replace('\n', '')
def ILCI(n: int): return [II() for _ in range(n)]
def ILCF(n: int): return [IF() for _ in range(n)]
def ILI(): return list(map(int, input().split()))
def ILLI(n: int): return [[int(j) for j in input().split()] for i in range(n)]
def ILF(): return list(map(float, input().split()))
def ILLF(n: int): return [[float(j) for j in input().split()] for i in range(n)]
def LTOS(lst: list, sep: str = ' '): return sep.join(map(str, lst))
def DEC(lst: list): return list(map(lambda x: x-1, lst))
def INC(lst: list): return list(map(lambda x: x+1, lst))


def main():
    N, K = ILI()

    ans = 0.0
    for i in range(1,N+1):
        scr = i  
        pb = 1.0  
        win = True  
        while True:
            if K <= scr:  
                EPR(scr)
                break
            elif 0 < scr < K:
                scr *= 2
                pb *= 0.5
            else:  
                scr = 0
                win = False
                break
        if win:
            ans += pb / N

    print("{:.12}".format(ans))


if __name__ == '__main__':
    main()

Solution (Python):








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

    cntlist=[0]*(N+1)
    for i in range(1,N+1):
        cnt=0
        j=i
        while j<K:
            j=j*2
            cnt+=1
        else:
            cntlist[i]=cnt
    for i in range(N+1):
        cntlist[i]=0.5**cntlist[i]

    print((1/N)*sum(cntlist[1:]))

resolve()

Solution (Python):
import math

n, k = map( int, input().split())
 
ans = 0
for i in range(1, n + 1):
  a = max( 0 , math.ceil(math.log( k / i, 2 )))
  ans += ( 1 / n ) * ( 0.5 ** a )
print(ans)

Solution (Python):

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

import math
ret = 0
log_k = math.log(K)
for n in range(1, N+1):
    prob = 1
    while n < K:
        prob *= 0.5
        n *= 2

    ret += prob


print(ret / N)

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

import math

prob = 0
for i in range(1, n + 1):
  a = max( 0 , math.ceil( math.log( k / i, 2 )))
  prob += ( 1 / n ) * ( 0.5 ** a )
print( prob )

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

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

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

Solution (Python):
import math

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

ans = 0

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

print(ans)

Solution (Python):
import math
n, k = map(int, input().split())
pro = 0.0
for p in range(1, n + 1):
    if p >= k:
        pro += 1.0 / n
    else:
        a = math.ceil(math.log2(k / p))
        pro += (1.0 / n) * (0.5**a)
print("{:.15f}".format(pro))

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

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

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

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

prob = []

for i in range(1,n+1):
	for j in range(10000):
		
		if k <= i*2**j:
			
			p = (1/n)*(1/2)**j
			prob.append(p)
			break

print(sum(prob))

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

L = [0]*N
num =1
for i in range(N):
    num = 1
    if i < K:
        while num*(i+1) < K:
            num *= 2
        L[i]= 1/N * 1/num
    else:
        L[i] = 1/N

ans = 0
for i in range(N):
        ans +=L[i]

print(ans)

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

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

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

ans = 0
for i in range(1, N + 1):
    k = K / i
    streak = 0
    while k > 1:
        k /= 2
        streak += 1
    ans += (1 / N) * 0.5**streak

print(ans)

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


prob_sum = 0
die_prob = 1/N

def find_flips(i):
    score = i
    flips = 0
    while score < K:
        score *=  2
        flips += 1
    return flips

for i in range(1,N+1):
        
        prob_sum += die_prob * (1/2)**(find_flips(i))

print(prob_sum)

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

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

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

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

Solution (Python):


import math


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

    result = 0
    for i in range(1, N + 1):
        cnt = max(math.ceil(math.log(K / i, 2)), 0)
        result += (1 / N) * (1 / 2)**cnt
    print(result)


if __name__ == "__main__":
    main()

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

for i in range(1, n+1):
    a = i
    cnt = 0
    while a < k:
        a *= 2
        cnt += 1
    ans += 1/(pow(2, cnt)*n)

print(ans)

Solution (Python):

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

ans = 0
for i in range(1, n + 1):
    cnt = 0
    if i >= k:
        ans += 1 / n
    else:
        j = i
        while j < k:
            j *= 2
            cnt += 1
        
        ans += 1 / n * 0.5 ** cnt
    

print(ans)

Solution (Python):
import math

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

Pro = 0

for i in range(1, N+1):
    try:
        count = math.ceil(math.log2(K / i))
        if count < 0:
            count = 0

    except ValueError:
        count = 0

    Pro += ((0.5) ** count) / N

print(Pro)

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

def succ(m): 
  res = 0
  while True:
    if m < k:
      res += 1
      m *= 2
    if m >= k:
      return res

def pos():
  res = 0
  for i in range (1, n+1):
    m = n*2**succ(i)
    res += 1/m
  return res

print(pos())

Solution (Python):
import math
tmp = 0
big_dice = 0
a,b = map(int, input().split())
log2_b = math.log2(b)
if a > b:
  c = b
  big_dice = (a - b) / a
else:
  c = a
for i in range(1, c + 1):
  log2_i = math.log2(i)
  n = math.ceil(log2_b - log2_i)
  tmp = tmp + 0.5**n
print(tmp / a + big_dice)

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

ans = []
for i in range(1, n + 1):
    rate = n
    score = i
    while score <= k - 1:
        score *= 2
        rate *= 2
    ans.append(1 / rate)

print(sum(ans))

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

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

ans = 0

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

print(ans)

Solution (Python):
n,k=map(int,input().split())
a=[]
def x(t,k):
  c=0
  while t<k:
    t*=2
    c+=1
  return c

for i in range(n):
  a.append(x(i+1,k))

ans=0
for i in range(n):
  ans=ans+1/n*(1/2)**a[i]
print(ans)

Solution (Python):
n,k = map(int, input().split())
y = 0
for i in range(1,n+1):
  for j in range(18):
    if i * 2**j > k-1:

      y += 1/(n*2**j)
      break
print(y)

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

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


table = [None] * k


def dfs(p):
    if p >= k:
        return 0
    elif table[p-1] != None:
        return table[p-1]
    return 1 + dfs(p * 2)

ans = 0
for i in range(n, 0, -1):
    ans += pow(0.5, dfs(i))
print(ans/n)

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

def check(i, K) :
    b = 0
    while i < K :
        b += 1
        i *= 2
    return 0.5**b

ans = 0
for i in range(1,N+1) :
    ans += check(i,K)/N

print(ans)

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

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

s1 = 1/n
s2 = 1/2
result = 0
for i in range(1,n+1):
    res = i
    cnt = 0
    while res < k:
        res *= 2
        cnt += 1
    result += s1*pow(s2,cnt)
print(result)

Solution (Python):

N,K=[int(x) for x in input().rstrip().split()]
ans=0
m=1
for i in range(1,N+1):
    
    while(i*m<K):
        m=m*2
    
    ans+=1/(m*N)
    m=1

print(ans)

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

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

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

ans = 0

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

Solution (Python):
N, K = map(int, input().split())
ans = 0
for i in range(1,N+1):
    tmp_i = 0
    while True:
        if i*2**tmp_i>=K:
            break
        tmp_i += 1
    ans += (1/N)*.5**tmp_i
print(ans)

Solution (Python):
n, k = map(int, input().split())
ans = []
for i in range(1, n+1):
    if i < k:
        j = i
        cnt = 0
        while j < k:
            j *= 2
            cnt += 1
        tmp = 1/n * ((1/2) ** cnt)
        ans.append(tmp)
    if i >= k:
        ans.append(1/n)
print(sum(ans))

Solution (Python):
import math

n, k = map(int, input().split())
ans = []
for i in range(1, n+1):
    if i < k:
        j = i
        cnt = 0
        while j < k:
            j *= 2
            cnt += 1
        tmp = 1/n * ((1/2) ** cnt)
        ans.append(tmp)
    if i >= k:
        ans.append(1/n)
print('{:.10f}'.format(sum(ans)))

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

def probability(p):
    if p >= K:
        return 1
    cnt = 0
    while(p < K):
        p = p * 2
        cnt += 1
    return 1 / (2 ** cnt)

ans = 0

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

print(ans)

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

Solution (Python):
from math import *
n,k=map(int,input().split())
e=0
for i in range(1,n+1):
  t=ceil(log2(k/i))
  e+=1*(t<1)or 2**-t
print(e/n)

Solution (Python):
import math
e=0
n, k = map(int, input().split())
for i in range(1,n+1):
  m = math.ceil(math.log2(k/i))
  e += 1*(m<1) or 2**-m
print(e/n)

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

pos=0
sum=0

for i in range(1,N+1):
    pos=1/N
    count=0
    while i<K:
        i*=2
        count+=1
    
    pos*=pow(1/2,count)
    sum+=pos



print(sum)

Solution (Python):
def 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/pow(2,max(int(math.ceil(math.log2(k/i))),0))         
  print(ans/n)
if __name__=='__main__':
  main()

Solution (Python):
def main():
  import sys
  input = sys.stdin.readline
  import numpy as np
  n,k=map(int,input().split())
  ans=0
  for i in range(1,n+1):
    ans+=1/pow(2,max(int(np.ceil(np.log2(k/i))),0))         
  print(ans/n)
if __name__=='__main__':
  main()

Solution (Python):
import math
n,k=map(int,input().split())
ans=0
for i in range(1,n+1):
  if i>=k:
    ans+=1/n
    continue
  x=math.ceil(math.log2(k/i))
  ans+=((1/2)**x)/n
print(ans)

Solution (Python):
N,K=map(int,input().split())
ans=0
for i in range(1,N+1):
    score=i
    cnt=0
    while(K>score):
        score=score*2
        cnt+=1
    ans+=(1/N)*(0.5**cnt)
print("{:.12f}".format(ans))

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

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

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

p = 0
for i in range(1,n+1):
    if i < k:
        r = 1
        while i < k:
            i *= 2
            r *= 1/2
        p += r
    else:
        p += 1

print(p/n)

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

for i in range(1, N + 1):
  cnt = 0
  S = i
  while S < K:
    cnt += 1
    S *= 2
    
  E += 0.5 ** cnt
  
print(E / N)

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

Solution (Python):

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


ans=0
for i in range(1,n+1):
    p=i
    count=0
    while p<k:
        count+=1
        p=p*2
    ans+=(0.5**count)
ans=ans/n
print('{:.11f}'.format(ans))

Solution (Python):

import sys
import math

def solve(N: int, K: int):
    inN = N
    sum = 0.0
    rate = 1.0
    if N >= K :
        sum += (N-(K-1))*rate
        N = K - 1
    while K >= 2:
        K = math.ceil(float(K)/2.0)
        rate /= 2.0
        if N > K-1:
            sum += (N-(K-1))*rate
            N = K - 1
    print(sum/float(inN))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    K = int(next(tokens))  
    solve(N, K)

if __name__ == '__main__':
    main()

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

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

points=[]
for i in range(N):
    x=K/(i+1)
    y=math.log(x)/math.log(2)
    y=max(0,math.ceil(y))
    z=pow(2,-math.ceil(y))
    points.append(z)
print(sum(points)/N)

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

Solution (Python):
n,k=map(int,input().split())
a=0
for i in range(n+1):
    for x in range(20):
        if i*(2**x) >= k:
            a+=(1/n)*((1/2)**(x))
            break
print(a)

Solution (Python):
n, k = map(int, input().split())
ans = float(0)
for i in range(1, n+1):
    cnt = 0
    while True:
        if i >= k:
            break
        i *= 2
        cnt += 1
    ans += 0.5**cnt
    

ans *= 1 / n
print(ans)

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

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

Solution (Python):

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

def cnt2(x):
    cnt=0
    while x<k:
        cnt+=1
        x*=2
    return cnt

for i in range(1,n+1):
    ans+=1/(n*2**cnt2(i))
    
print(ans)

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

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

prob = num_of_heads =  0
for i in range(n, 0, -1):
    while i * 2 ** num_of_heads < k:
        num_of_heads += 1
    prob += (1/n) * (1/2)**num_of_heads

print(prob)

Solution (Python):
import math
n,k = [x for x in list(map(int,input().split()))]
prob = 0
for i in range(1,n+1):
    number = math.ceil(math.log(math.ceil(k/i),2))
    prob+=(1/2)**number
prob*=(1/n)
print(prob)

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

prob_win = 0.0
for i in range(1, N+1):
    pnt = i
    cnt = 0
    while(True):
        if pnt >= K:
            break
        pnt *= 2
        cnt += 1
    prob_win += (1/N) * (1/2)**cnt

print(prob_win)

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

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

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

while m > 0:
    if k <= m:
        ans += (m - k + 1)/n * 0.5**q
        m = k - 1
    k = k // 2 + k % 2
    q += 1

print(ans)

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

Solution (Python):
def main():
    N, K = (int(i) for i in input().split())
    ans = 0
    for i in range(1, N+1):
        cur = i
        cur_p = 1/N
        while cur < K:
            cur *= 2
            cur_p /= 2
        ans += cur_p
    print(ans)


if __name__ == '__main__':
    main()

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

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

print(ans)

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

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

total = 0
win = 0
p = 0.0
for n in range(1, N+1):
  t = n
  c = 0
  while t < K:
    c += 1
    t *= 2
  p += 0.5**c * 1/N
  
print(p)

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

ans = 0
for x in range(1, N+1):
    if x >= K:
        ans += 1
        continue
    t = 1
    while x < K:
        x<<=1
        t<<=1
    ans += 1/t

print(ans / N)

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

t = 0
import math
for x in range(1, min(N,K-1)+1):
    t += (1-pow(0.5, math.ceil(math.log2(K/x))))

print(1 - t / N)

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

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

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

    ans+=(1/n)*(1/2)**cnt
print(ans)

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

import math
ans = 0
for i in range(1, n+1):
    if i >= k:
        t = 0
    else:
        t = math.ceil(math.log2(k/i))
    
    ans += (1/n)*((1/2)**t)
print(ans)

Solution (Python):

import math
n,k = map(int,input().split())
m = min(n, k)
win = 0
for i in range(1, m + 1):
    a = math.ceil(math.log2(k / i)) 
    win += 1 / n * pow(1 / 2, a) 
    
win += 1 / n * max(0, n - k) 
print(win)

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

from math import log,ceil

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

print(ans)

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

    for j in range(cnt):
        add/=2
    ans+=add

print(ans/n)

Solution (Python):
import math
n,k=map(int,input().split())
a=0
k=math.log2(k)
for i in range(n):
    a+=2**-max(math.ceil(k-math.log2(i+1)),0)/n
print(a)

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

ans = 0
for d in range(1, N+1):
    cnt = 0
    while d < K:
        d *= 2
        cnt += 1
    ans += 1 / (N * pow(2, cnt))

print(ans)

Solution (Python):
import math

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

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

Solution (Python):



from math import ceil, log2

def main():
  n, k = map(int, input().strip().split())
  p = 1/n
  s = 0
  for x in range(1, n+1):
    if x >= k:
      s += p
    else:
      s += p * (1/2 ** ceil(log2(k/x)))
  print(s)

if __name__=='__main__':
  main()

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

ans=0
prob=1/n
coins=1/2

for i in range(1,n+1):
    cnt=1
    tmp=i
    if tmp >= k:
        ans+=prob
    else:
        while tmp*2 < k:
            tmp=tmp*2
            cnt+=1
        ans+=prob*(coins**cnt)

print(ans)

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

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

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

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

        rate += 1 / t

    print(rate / N)


main()

Solution (Python):


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


class Result:
    def __init__(self, win: int, lose: int):
        self.win = win
        self.lose = lose
        self.total = win + lose


dic = {}


def get_ans(current: int):
    if current >= k:
        return Result(1, 0)
    if current in dic:
        return dic[current]
    ret = get_ans(current * 2)
    ret = Result(ret.win, ret.lose + ret.total)
    dic[current] = ret
    return ret


result_list = [get_ans(i) for i in range(1, n+1)]
max_total = max([i.total for i in result_list])

win_total = 0
lose_total = 0
for i in result_list:
    mul = int(max_total / i.total)
    win_total += i.win * mul
    lose_total += i.lose * mul

print(win_total/(win_total+lose_total))

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

p = 0
p += max(0,(n - k) / n)

p += sum([ 1 / n * (1 / 2 ** math.ceil(math.log2(k/x))) for x in range(1,n - max(0,n - k)+1)])

print(p)

Solution (Python):
def cal(i):
    kaisu = 0
    while(i<k):
        i *= 2
        kaisu += 1
    return (1/(n*1.0))*pow((1/2.0),kaisu)

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

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

print(ans)

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

s = 0
for i in range(1, n+1):
    j = 0
    if i >= k:
        s += 1 / n
    else:
        while True:
            if i * 2 ** j >= k:
                s += (1 / n) * 0.5 ** j
                break
            j += 1

print(s)

Solution (Python):
def cnt(a,b):
    ret = 0
    while a < b:
        a *= 2
        ret += 1
    return ret

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

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

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

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

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

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

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

import math
ans = 0.0
for i in range(1,n+1):
  tmp = 1/n
  a = i
  while a<k:
    a*=2
    tmp/=2
  ans += tmp
  
print(ans)

Solution (Python):
import sys 
from decimal import Decimal
readline = sys.stdin.buffer.readline
N,K = map(int, readline().split())
l = [2**i for i in range(18)]
ans = 0
for i in range(1,N+1):
  for j in l:
    if i*j < K:
      continue
    ans += 1/j
    break
print(ans/N)

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