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):
from functools import reduce
from operator import mul


def end_of_loop():
    raise StopIteration


def main():
    N, K = map(int, input().split())
    print(sum([reduce(mul, (0.5
                            if i << j < K
                            else end_of_loop()
                            for j in range(K)), 1 / N)
               for i in range(1, N + 1)]))
    return


main()

Solution (Python):
from functools import reduce
from operator import mul


def main():
    N, K = map(int, input().split())
    ans = []
    lst = []
    for i in range(1, N + 1):
        lst.clear()
        for j in range(K):
            if K <= i << j:
                break
            lst.append(0.5)
        ans.append(reduce(mul, lst, 1 / N))
    print(sum(ans))
    return


main()

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

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

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

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

Solution (Python):

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

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

print(ans)

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

ans1=0

if n>=k:
	ans1=(n-k+1)/n
	
	ans2=0
	ans=0
	for i in range(k-1):
		j=1
		while (i+1)*2**j<k:
			j=j+1
	
		ans2=(1/2)**j
		
		
		ans=ans+ans2

	ans=ans1+1/n*ans

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

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

Solution (Python):


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

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

print(ans)

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

dict ={}
list = []

for i in range(n, 0,-1): 
    list.append(i)


count_dict = {}
sum = 0
count = 0
i = 0
while(i <= len(list)-1):
    if k / list[i]  <= 2 ** count:
        
        
        
        if count not in count_dict:
            count_dict[count] = 1
        else:
            count_dict[count] += 1
        
        i += 1
    else:
        count += 1

max_count = max(count_dict)

for i in range(max_count + 1):
    
    if i in count_dict:
        sum += count_dict[i] / (2 ** i)
        

print(sum/n)

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

if K == 1:
    print(1)
    exit()

if N < K:
    P = 0
    for i in range(1, N + 1):
        temp = 1
        while i * (2 ** temp) < K:
            temp += 1
        P += (1 / N) * (1 / 2) ** temp
else:
    P = (N - (K - 1)) / N
    for i in range(1, K):
        temp = 1
        while i * (2 ** temp) < K:
            temp += 1
        P += (1 / N) * (1 / 2) ** temp
print(P)

Solution (Python):
import math

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

if K==1:
    print(1)
    exit()

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

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

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

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

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

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

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
    else:
        ans+=(1/n)*(1/2)**math.ceil(math.log2(k/i))
print(ans)

Solution (Python):
import math

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


prob = max(0,(N-K+1)/N)
log_2_K = math.log2(K)

for dice in range(1,min(K,N+1)):
    prob += (1/N)*(1/2**(math.ceil(log_2_K - math.log2(dice))))

print(prob)

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

if __name__ == '__main__':
    solve()

Solution (Python):
n, k = map(int, input().split())
class Dice:
    def __init__(self,point,count):
        self.point = point
        self.count = count
dice = [Dice(i, 0) for i in range(1,n+1)]
p = []
for i in range(n):
 while 1<= dice[i].point <= k-1:
    dice[i].point *= 2
    dice[i].count += 1

 p.append(0.5 ** dice[i].count)

print(sum(p) / n)

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

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

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

Solution (Python):
import math
n,k = map(int, input().split())
m = n
ans = 0
if n >= k:
  ans += (n-k+1)/n
  m = k-1

p=2
while m > 0:
  if m * p >= k:
    a = m - math.ceil(k/p) + 1
    ans += a/n/p
    m -= a
  p *= 2

print(ans)

Solution (Python):
import math
n,k=map(int,input().split())
p=0
for i in range(1,n+1):
 if i<k:
  p+=(1/2)**(-(-math.log(k/i,2)//1))
 else:
  p+=1
print(p/n)

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

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

if N >= K:
  s = (N-K+1) / N
else:
  s = 0

for i in range (1,min(N+1,K)):
  a = K / i
  x = math.ceil(math.log(a,2))
  s = s + (1/2) ** x / N
print(s)

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

Solution (Python):
import numpy as np

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

count = 0.

for i in range(1,num+1):
    if i <= k-1:
        times = np.log2(k/i)
        if times != int(times):
            times = int(times) +1
        else:
            times = int(times)
        count += (1/num) * (1/2)**times
    elif i >= k:
        count += 1/num
print(count)

Solution (Python):
import math

N,K=map(int,input().split())
ans=0
for i in range(1,N+1):
    ans+=(1/N)*min((1/2)**math.ceil(math.log2(K/i)),1)
print(ans)

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

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

Solution (Python):
import math

N,K=map(int,input().split())
ans=0
p1=1/N
for i in range(1,N+1):
    if i>=K:
        ans+=p1
        continue
    n=math.log2(K/i)
    if n==int(n):
        p2=0.5**n
    else:
        p2=0.5**(int(n+1))
    ans+=p1*p2
print(ans)

Solution (Python):
from decimal import Decimal
N,K=map(int,input().split())
ans = 0
for i in range(1,N+1):
    if i >=K:
        ans+=N-i+1
        break
    tmp = i
    t_k = 1
    while tmp < K:
        tmp = tmp*2
        t_k = t_k*2
    ans += Decimal(1/t_k)
print(Decimal(ans/N))

Solution (Python):
import sys
from bisect import *
from collections import *
from copy import deepcopy
from datetime import *
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

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

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

if __name__ == '__main__':
    main()

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

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

Solution (Python):
n,k = map(int,input().split())
p = []
for i in range(1,n+1):
    ti = i
    pn = 0
    while ti < k:
        ti *= 2
        pn += 1
    p.append(pn)

res = 0
for pn in p:
    res += 1/(2** pn)

print(res / n)

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

sum_pro = 0 
for i in range(N):
  i_ = i+1
  if(i_ < K):
   p_i = math.ceil(math.log2(K/i_))
   sum_pro += (1/(2**p_i))*(1/N)
  else:
   sum_pro += 1/N
                
print(sum_pro)

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

Solution (Python):
import math
n,k = map(int,input().split())
prob = 0.0
for i in range(1,n+1):
  if i >= k:
    prob += 1/n
  else:
    omote_count = math.ceil(math.log2(k/i))
    prob += ((1/2)**omote_count ) * (1/n) 
  
print(prob)

Solution (Python):
N, K = map(int,input().split())
win = 0
if N >= K:
    for i in range(1,K):
        
        j =0
        while i*(2**j) < K:
            
            j +=1
        win += 1/((2**j)*N)
    
    win += (N-K+1)/N
else:
    for l in range(1,N+1):
        
        m = 0
        while l*(2**m) < K:
            
            m +=1
        win +=1/((2**m)*N)

print(win)

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

Solution (Python):
import sys
input = sys.stdin.readline
import math

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

    ans = 0

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

    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):
from math import ceil
n,k = map(int, input().split())
bi = [2**i for i in range(1000)]
ans = 0
for i in range(1,n+1):
    if i >= k:
        ans += 1 / n
        continue
    for j in range(1,k+1):
        if i * bi[j] >= k:
            
            break
    ans += (0.5**j) / n
print('{:.10f}'.format(ans))

Solution (Python):
n,k = map(int, input().split())
a=[]
while k>1:
    a.append(k)
    k/=2
a.append(k/2)
ans=0
c=0
b=n
while n>=1:
    if n>=a[c]:
        ans+=(2**(-c))*(1/b)
        n-=1
    else:
        c+=1
print(ans)

Solution (Python):
N,K=map(int,input().split())
L=[]
for i in range(1,N+1):
  l=0
  while i*2**l<K:
    l+=1
  else:
    L.append(l)
ans=0
for m in range(N):
  ans+=1/N*((1/2)**L[m])
print(float(ans))

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    t = 0
    for i in range(1, n + 1):
        cnt = 0
        ti = i
        while True:
            if ti >= k:
                t += (((1 / 2) ** cnt) * 1 / n)
                break
            else:
                ti *= 2
                cnt += 1
    print(t)


if __name__ == '__main__':
    slove()

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

def win(x):
    prob = 1.0
    while K > x:
        prob /= 2
        x *= 2
    return prob / N

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

print(ans)

Solution (Python):
n, k = map(int, input().split())
ans = 0
for i in range(1, n+1):
    tmp = 1.0/n
    now = i
    while now < k:
        now *= 2
        tmp /= 2
    ans += tmp
print("{:.12f}".format(ans))

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

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

Solution (Python):

import math

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

data=[[0,1]]
for i in range(1,19):
    data.append([i,2**i])

j=0
while n*data[j][1]<k:
    j+=1

a=0
i=n

while i>=1:
    if i*data[j][1]>=k:
        a+=1/(n*data[j][1])
    else:
        j+=1
        a+=1/(n*data[j][1])
    i-=1

print(a)

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

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

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

Solution (Python):
n, k = map(int, input().split())
max_multiple_count = 0
max_multiple = 1
while max_multiple < k:
    max_multiple_count += 1
    max_multiple *= 2

if n - k >= 0:
    ans = (n - k + 1)/n
else:
    ans = 0
for i in range(1, min(n+1, k)):
      I = i
      for j in range(1, max_multiple_count+1):
            I *= 2
            if I >= k:
                ans += (1/n) * ((1/2)**j)
                break

print(ans)

Solution (Python):
n, k = map(int, input().split())
max_multiple_count = 0
min_multiple_count = 0
max_multiple = 1
min_multiple = min(n, k-1)
while max_multiple < k:
    max_multiple_count += 1
    max_multiple *= 2

if n - k >= 0:
    ans = (n - k + 1)/n
else:
    ans = 0
for i in range(1, min(n+1, k)):
      I = i
      for j in range(1, max_multiple_count+1):
            I *= 2
            if I >= k:
                ans += (1/n) * ((1/2)**j)
                break

print(ans)

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

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

ans = max(N-K+1, 0) / N
for i in range(1, min(N+1, K)):
    c = 0
    while i*2**c < K:
        c += 1
    ans += (0.5**c)/N

print(ans)

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

Solution (Python):
def doubling(i, k):
    while i < k:
        i *= 2
    return i


n, k = map(int, input().split())
p = 0
for i in range(1, n + 1):
    p += (i / doubling(i, k)) / n
print(p)

Solution (Python):
from math import ceil

N, K = map(int, input().split())
ans = 0
for i in range(1, N+1):
    A = ceil(K/i)
    B = 1
    while(B < A):
        B = B << 1
    ans += 1/(N*B)
print(ans)

Solution (Python):

import math
N,K=map(int,input().split())
ans=0
A=[]

while(K>0):
  A.append(K)
  if K==1:
    K-=1
  K=math.ceil(K/2)

x=1/N

for i in range(len(A)):
  if N>=A[i] and ans==0:
    ans +=(N-A[i]+1)*x*((1/2)**i)
  elif N>=A[i] and ans>0:
    ans +=(A[i-1]-A[i])*x*((1/2)**i)
  

print(ans)

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

    ans = 0
    for i in range(1, n + 1):
        t = i
        c = 1
        for j in range(100):
            if t >= k:
                break
            t *= 2
            c += 1
        c -= 1
        ans += (1 / n) * ((1 / 2)**c)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import math

n, k = map(int, input().split())
ans = 0
for i in range(1, n + 1):
    ans += 1 / n * min((1 / 2) ** math.ceil(math.log2(k / i)), 1)

print(ans)

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

ans = 0

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

print(ans)

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

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

Solution (Python):
import math


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

possibility = 0.0

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

    cnt = 0

    while i < K:
        i *= 2
        cnt += 1

    tmp_possibility = 1 / N * (0.5 ** cnt)

    possibility += tmp_possibility

print(possibility)

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

result=0.0

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

Solution (Python):
def test():
    n,k = map(int,input().split())
    a = []; ans = 0
    for i in range(1,n+1):
        result = i
        count = 1
        while result < k:
            result *= 2
            count /= 2
        ans += count
    print("{:.12f}".format((1/n)*ans))



if __name__ == "__main__":
    test()

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

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

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

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

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



n, k = LI()

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



print(ans / n)

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

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

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

Solution (Python):
def f_c():
    n, k = map(int, input().split())
    a = 0
    for i in range(1, n+1):
        c, v = 0, i
        while True:
            if v>=k:
                break
            c, v = c+1, v*2
        a += (1/n)*(1/2)**c
    print(a)

if __name__ == "__main__":
    f_c()

Solution (Python):
me,goal = map(int,input().split())
probabilities = []

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

    t = 0
    while True:
        if i>=goal:
            ans += (1/2**t)/me
            break

        i *= 2
        t += 1

print(ans)

Solution (Python):
import math
eps = 10**(-8)
N,K = map(int,input().split())
L = min(N,K-1)
cnt = 0
for i in range(1,L+1):
    a = math.log(K/i)/math.log(2)
    if abs(a-round(a))<eps:
        a = round(a)
    else:
        b = int(a)
        if a>b+eps:
            a = b+1
        else:
            a = b
    cnt += 2**(-a)
print(max(1-(K-1)/N,0)+cnt/N)

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

Solution (Python):
import math

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

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

print(ans)

Solution (Python):

N,K=map(int, input().split())
ans=0
m=0
for i in range(1,N+1):
    if i<=K:
        m=0
        n=i*(2**m)
        while n<K:
            m+=1
            n=i*(2**m)
        ans+=(1/(N*(2**m)))
    else:
        ans+=(N-K)/N
        break
print(ans)

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

print(prob)

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

Solution (Python):

def main():
    N,K = map(int,input().split())
    ans = 0
    for i in range(1,N+1):
        n = 0
        while i < K:i*=2;n+=1
        ans += ((1/N)*(1/2)**n)
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):

def main():
    N,K = map(int,input().split())
    ans = 0
    for i in range(1,N+1):
        tmp = i
        n = 0
        while tmp < K:tmp*=2;n+=1
        ans += ((1/N)*(1/2)**n)
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
import math

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

P = 0
P_log2 = 1

for i in range(1, N+1):
    if i < K:

        T = math.ceil(math.log2(K / i))
        P += 1/ N * 1 / (2 ** T)

    else:
        P += 1 / N

            
print(P)

Solution (Python):
from itertools import accumulate
import sys
from heapq import heappush, heappop
import math


def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    p = 0
    for n in range(1, N+1):
        c = max(math.ceil(math.log2(K / n)), 0)
        p += 1 / N * 0.5 ** c
    print(p)


if __name__ == '__main__':
    main()

Solution (Python):
N,K = map(int,input().split())
Klist = []
temp = K
ans = 0
amari = 0


while temp>=1:
    Klist.append(temp)
    temp = -(-temp//2)
    if temp==1:
        Klist.append(temp)
        break

powcount = 0

while True:
    if N >= Klist[powcount]:
        amari = N - Klist[powcount]
        break
    powcount += 1
    
for i in range(powcount,len(Klist)):
    if i==powcount:
        ans += (N-Klist[powcount]+1)/pow(2,powcount)
        
    else:
        ans += (Klist[i-1]-Klist[i])/pow(2,i)
        
        
print(ans/N)

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

res = 0.0

for i in range(1, N + 1):
    c = 0
    while 2 ** c < K / i:
        c += 1
        
    res += (1 / N) * ((1 / 2) ** c)

print(res)

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

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

Solution (Python):
import math

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

count = 0
max_count = math.ceil(math.log2(k))
total = n * (2 ** max_count)

for i in range(1, n+1):
    if k >= i:
        t = math.ceil(math.log2(k/i))
        count += 2 ** (max_count - t)
    else:
        count += 2 ** max_count

print(count / total)

Solution (Python):
import sys
n,k = map(int,input().split())
if k == 1:
    print(1)
    sys.exit()
a = n
n0 = n
i = 0
sum = 0
power_list = [0] * 24
if n > k:
    power_list[0] = n - k + 1
    n = k - 1
    a = k 
i = 1
a = k
while a != 1:
    if a % 2 == 0 and a//2 > n:
        a = a//2
        k = a
        i += 1
    elif a % 2 == 0 and a//2 <= n:
        power_list[i] = n - a//2 + 1
        n = a//2 - 1
        a = a//2
        i += 1
    else:
        a += 1
for i in range(24):
    sum += (1/2)**i * power_list[i] / n0

print(sum)

Solution (Python):
import math

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

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

print(ans)

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

if N <= K-1: 
  for i in range(1, N+1):
    katsu += 0.5 ** ((math.log2((K-1) / i) // 1)+1) 
  print(katsu/N)
  exit()
else: 
  for i in range(1, K):
    katsu += 0.5 ** ((math.log2((K-1) / i) // 1)+1) 
  for i in range(K, N+1):
    katsu += 1
  
  print(katsu/N)
  exit()

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


l = []
for i in range(1,n+1):
    ct = 0
    while i < k:
        ct += 1
        i *= 2
    l.append(0.5**ct)
    
print(sum(l)/n)

Solution (Python):
n,k = map(int, input().split())
a = k
l =[]
ans_temp = 0

while True:
  a /= 2
  l.append(a)
  if a <= 1:
    break

def sum_num(x):
  sum_temp = 0
  for i in range(1, x):
    for j in range(len(l)):
      if l[j] <= i:
        sum_temp += 0.5**(j+1)
        break
  return sum_temp

if n < k:
  ans_temp += sum_num(n+1)
else:
  ans_temp += sum_num(k) + (n - k + 1)

print(ans_temp / n)

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

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

for i in range(1,n+1):
    point = 0
    if i >= k:
        ans += 1/n
    else:
        point = i
        count = 0
        while point < k:

            point *= 2
            count += 1
        ans += (1/n)*((1/2)**count)

print(ans)

Solution (Python):
while True:
    try:
        n, k = map(int, input().split())
        ans = 0
        for num in range(1, n+1):
            count = 0
            while True:
                if num >= k:
                    break
                else:
                    num *= 2
                    count += 1
            ans += 1 / 2**count
        print(ans/n)
    except:
        break

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

Solution (Python):

import sys
import math


def solve(N: int, K: int):
    l = [(1 / 2) ** max(0, math.ceil(math.log2(K / i))) for i in range(1, N + 1)]
    print(sum(l) / len(l))
    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 = list(map(int,input().split()))
ans = 0
for i in range(N):
  a = i+1
  b = 1
  while a<K:
    a = a*2
    b = b*0.5
  ans += b*1/N
print(ans)

Solution (Python):
if __name__ == '__main__':
    N, K = map(int, input().split())
        
    prob = 0
    
    for i in range(1, N+1):    
        for n in range(1000):
            if K <= i*2**n:
                num = n
                break
        
        prob += (1/N)*((1/2)**num)
    print(prob)

Solution (Python):
import math
while True:
    try:
        N, K = map(int, input().split())
        
        P = 0
        if K <= N:
            P = (N-K+1) / N
            
        for i in range(1, min(K, N+1)):
            p = math.ceil(math.log2(K/i))
            P += (1/N) * (0.5**p)
        print(P)
    except:
        break

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

ans = Decimal(0)
m = n+1

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

Solution (Python):
import math

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

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

print(res)

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

print(calc)