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
input = sys.stdin.readline
N,K = [int(i) for i in input().split()]
P = 0
score = 0
count = 0
for n in range(1,N+1) :
    score = n
    while score < K :
        score*=2
        count+=1
    P += (1/N) * (1/2) ** count
    score = 0
    count = 0
print(P)

Solution (Python):

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

probs = []
keisuu = 1 / N
for dice in range(1, N + 1):
    score = dice
    cnt = 0
    while score < K:
        score *= 2
        cnt += 1
    probs.append(keisuu * (1 / 2)**cnt)


print(sum(probs))

Solution (Python):

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

probs = []
keisuu = 1 / N
for dice in range(1, N + 1):
    score = dice
    cnt = 0
    while score < K:
        score *= 2
        cnt += 1
    probs.append(keisuu * (1 / 2)**cnt)


print(sum(probs))

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

if N<K:
	for i in range (1,N+1):
		
		count = 1
		while(1):
			
			if i*2**count < K:
				count += 1
			else:
				break
		tmp += float(1/N)*float(1/(2**count))
else:
	for i in range (1,K):
		
		count = 1
		while(1):
			
			if i*2**count < K:
				count += 1
			else:
				break
		tmp += float(1/N)*float(1/(2**count))
	tmp += float(N-K+1)*float(1/N)
print(tmp)

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

Solution (Python):
import math

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

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

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

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

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

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

ans = 0
for i in range(1,n + 1):
    double = i
    for j in range(1000):
        if double >= k:
            break
        else:
            double = double << 1
    ans += (1 / n) * ((1 / 2)**j)

print(ans)

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

exp = 0
for i in range(1, n+1):
    count = 0
    while i < k:
        i *= 2
        count += 1
    exp += 0.5 ** count

print(exp / n)

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

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

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

print(ans)

Solution (Python):
N,K = map(int,input().split())
tmp = K/N
q = 1
p = 2 ** 20
while p/q >2:
    qp = q*2
    if qp > tmp:
        p = qp
    else:
        q = qp
res = 0
for i in range(N,0,-1):
    ans = i*q
    if ans < K:
        q*=2
    res+= float(1)/q
print(res/N)

Solution (Python):
N,K = map(int,input().split())
tmp = K/N
q = 1
p = 2 ** 100
while p/q >2:
    qp = q*2
    if qp > tmp:
        p = qp
    else:
        q = qp
res = 0
for i in range(N,0,-1):
    ans = i*q
    if ans < K:
        q*=2
    res+= float(1)/q
print(res/N)

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

    res += 0.5**(aro)
print(res/N)

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

    res += 0.5**(aro-1)
print(res/N)

Solution (Python):
l = []
M = 10000
h = 1
l.append(h)
while h < M:
    h*=2
    l.append(h)

N,K = map(int,input().split())
ans = 1
res = 0
for i in range(N):
    ans = i + 1
    tmp = 1
    aro = 1
    while ans < K:
        ans *= 2
        tmp = 0.5**aro
        aro += 1

    res += tmp
print(res/N)

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n,k = LI()

ans = 0
for i in range(1,n+1):
    tmp = i
    x = 1/n
    while tmp < k:
        tmp *= 2
        x *= 0.5
    ans += x
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
    else:
        j = math.ceil(math.log2(k/i))
        ans += (1/2)**j
print(ans/n)

Solution (Python):
N, K = map(int, input().split())
m = min(N, K)
n = N - m
p = n
for i in range(m):
  k = 1
  while K > (i + 1) * k:
    k *= 2
  p += 1 / k
print(p / N)

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

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

print(ans)

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

print(ans)

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

for i in range(N):
    
    j = 1
    k = j + i
    
    while k < K:
        
        j /= 2
        
        k *= 2
    
    win += j
print(win/N)

Solution (Python):

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

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

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

if __name__ == '__main__':
	main()

Solution (Python):


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

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

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

print(ans)

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

print(ans)

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

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

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

print(ans)

Solution (Python):
import math
N,K=[int(s) for s in input().split()]
a=0
for i in range(N):
  a+=2**(-max([0,math.ceil(math.log2(K/(i+1)))]))
print(a/N)

Solution (Python):


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

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

print(ans)

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

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

ans = 0

n = 0

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

print(ans)

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

ans = 0

ans += max(0, N-K+1)/N

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

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

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

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

Solution (Python):

n, k = map(int, input().split())
rate = 0
for i in range(1, n + 1):
  count = 0
  while True:
    if i * (2 ** count) >= k:
      break
    count += 1
  rate = rate + ((1 / n) * (1 / (2**count)))

print(rate)

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

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

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

Solution (Python):
import math
n, k = map(int, input().split())
ans = 0
if n >= k: ans += n - k + 1
p = 1/2
while k > 1:
  if n >= k: ans += p * (k - math.ceil(k / 2))
  elif n >= k / 2: ans += p * (n - math.ceil(k / 2) + 1)
  k = math.ceil(k / 2)
  p /= 2
print(ans / n)

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

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

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

Solution (Python):
n, k = map(int, input().split())
ans = 0
point = 0
count = 0
for i in range(1, n + 1):
    point = i
    while (not (point >= k)):
        point *= 2
        count += 1
    ans += (1 / n) * (1 / 2)**count
    point = 0
    count = 0
print("{:.9f}".format(ans))

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

pro_won = list()

for i in range(1, N+1):
    u = i
    z = 0
    cnt = 0
    if K <= u:
        z = 1/N
        pro_won.append(z)
    else:
        while u < K:
            u = 2*u
            cnt +=1
        z = (0.5**cnt)/N
        pro_won.append(z)
print(sum(pro_won))

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

ret = 0.0
for i in range(1, N + 1):
    
    tmp = 1.0 / N
    
    now = i
    while now < K:
        
        now *= 2  
        tmp /= 2  
    ret += tmp
    
print("{:.12f}".format(ret))

Solution (Python):

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

from decimal import Decimal
k = Decimal(k)
n_list = [Decimal(i) for i in range(n,0,-1)]
coin_cnt_list = [0] * n
cur_coin_cnt = 0
cur_pow_coin_cnt = 1

for i,v in enumerate(n_list):
    while v * cur_pow_coin_cnt < k:
        cur_coin_cnt+=1
        cur_pow_coin_cnt*=2
    coin_cnt_list[i]=cur_coin_cnt

from collections import defaultdict
d = defaultdict(int)

for key in coin_cnt_list:
    d[key] += 1

ret = Decimal(0)
for k,v in d.items():
    ret += 1/Decimal(2**k) * Decimal(v)
ret /= Decimal(n)
print(ret)

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

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

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

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

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

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

for i in range(1, n + 1):
    num = 1

    while i * num < k:
        num *= 2
    ans += 1 / num
print(ans / n)

Solution (Python):
import math


def main():
    N, K = map(int, input().split())
    accum = 0
    for i in range(1, len(bin(K)) - 2 + 1):
        cur = max(0, N - (math.ceil(K * 0.5 ** i)) + 1) * 0.5 ** i
        pre = max(0, N - (math.ceil(K * 0.5 ** (i - 1))) + 1) * 0.5 ** i
        accum += cur - pre
    print((max(0, N - K + 1) + accum) / N)
    return


main()

Solution (Python):
import math


def main():
    N, K = map(int, input().split())
    print((max(0, N - K + 1) + sum(
        max(0, N - (math.ceil(K * 0.5 ** i)) + 1) * 0.5 ** i
        - max(0, N - (math.ceil(K * 0.5 ** (i - 1))) + 1) * 0.5 ** i
        for i in range(1, len(bin(K)) - 2 + 1))) / N)
    return


main()

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

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

Sum = 0

for i in range(1,N+1):

    j = 0

    while (2 ** j) * i < K:
        j += 1
    i -= 1
    Sum += 1/(2 ** j)
    

print(Sum / N)

Solution (Python):
def double(i, k):
    cnt = 0
    while True:
        if i >= k:
            break
        i *= 2
        cnt += 1
    return cnt


def main():
    N, K = map(int, input().split())
    ans = 0
    for i in range(1, N+1):
        ans += 1/N * (0.5**double(i, K))
    print(ans)

if __name__ == '__main__':
    main()

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

Solution (Python):
import math


def main():
    N, K = map(int, input().split())
    print((max(0, N - K + 1) + sum(
        max(0, N - (math.ceil(K * (1 / 2) ** i)) + 1) * (1 / 2) ** i
        - max(0, N - (math.ceil(K * (1 / 2) ** (i - 1))) + 1) * (1 / 2) ** i
        for i in range(1, len(bin(K)) - 2 + 1))) / N)
    return


main()

Solution (Python):
import math


def main():
    N, K = map(int, input().split())
    print((max(0, N - K + 1) + sum(
        max(0, N - (math.ceil(K * (1 / 2) ** i)) + 1) * (1 / 2) ** i
        - max(0, N - (math.ceil(K * (1 / 2) ** (i - 1))) + 1) * (1 / 2) ** i
        for i in range(1, len(bin(K)) - 2 + 1 + 1))) / N)
    return


main()

Solution (Python):
import sys
import math
if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N, K = MAP()

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

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

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

print(ans)

Solution (Python):
import sys
import math
n, k = [int(i) for i in sys.stdin.readline().split()]
res = 0
for i in range(1, n+1):
    if i >= k:
        res += 1 / n
    else:
        res += 1 / 2 ** math.ceil(math.log2(k / i)) / n
print(res)

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

ans = 0

for i in range(1, n+1):
    for j in range(10**5):
        if i*(2**j) >= k:
            ans += 1 / (n * (2 ** j))
            break
print(ans)

Solution (Python):
import math
n,k=map(int, input().split())
ans=0
if n>k:
    ans+=n-k
for i in range(min(n,k),0,-1):
    t=-(-math.log(k/i,2)//1)
    win=1/(2**t)
    ans+=win
print(ans/n)

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

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

print(sum(p)/n)

Solution (Python):
import math
def main():
    N, K = map(int, input().split())
    l = [0] * (math.ceil(math.log2(K)) + 1)
    t = 2
    for i in range(len(l)):
        l[i] = t * 1/2
        t = l[i]
    p = 0
    for i in range(1, min(K, N+1)):
        p += l[math.ceil(math.log2(K/i))]
    p += max(N-K + 1, 0)
    p /= N
    return p

print(main())

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

half = k / 2
while True:
  half_list.append(half)
  half = half / 2
  if half < 0.5:
    break

half_list.reverse()

ans = 0

for i in range(1, n+1):
  
  i_prob = 1 / n
  
  half_i = 0
  for j in range(len(half_list)):
    if i >= half_list[j]:
      half_i = j
    else:
      break
  omote_count = len(half_list) - (half_i + 1)
  
  ans += i_prob * ((1 / 2) ** omote_count)
  

print(round(ans, 12))

Solution (Python):
n, k = map(int, input().split())
prob = 0
for init in range(1, n+1):
  for i in range(10000000):
    point = init * 2**i
    if point >= k:
      p = 0.5**i    
      break
  prob += p
print(prob / n)

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

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

ans = 0

for i in range(1, n+1):
  cnt = 0
  x = i
  while x <= k-1:
    x = x * 2
    cnt += 1
  ans += 1 / (2**cnt)
  
print("{0:.12f}".format(ans/n))

Solution (Python):
import math

n, k = map(int, input().split())
res = 0
for num in range(1, n+1):
    if num >= k:
        res += 1/n
    else:
        res += 1/n * (1/2) ** math.ceil(math.log2(k/num))
    pass
print(res)

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

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

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

for i in range(1,n+1):
  j=0 
  
  while i<k:
    i*=2
    j+=1
  ans+=1/2**j
print("{:.12}".format(ans/n))

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

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

print(prob)

Solution (Python):
import math

N, K = map(int, input().split())
ans = 0
for n in range(1, N+1):
    _ans = 1/N
    score = n
    while score < K:
        _ans *= 1/2
        score *= 2
    ans += _ans
print(ans)

Solution (Python):
import math

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

ans = 0
for n in range(1,N+1):
  a = max(0,math.ceil(math.log2(K/n)))

  a = (0.5**a)/N

  ans+=a
  

  
print(ans)

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

prob=0.0
for i in range(1,N+1):
    value = math.ceil(K / i)
    cnt = math.ceil(math.log2(value))
    prob += (1 / N / (2 **cnt))

print(prob)

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

p = sum(Fraction(1, 2**math.ceil(math.log2(K / n))) for n in range(1, min(N, K - 1) + 1)) / N
p += max(0, Fraction(N - K + 1, N))

print(float(p))

Solution (Python):
import math
import heapq
import sys
from collections import Counter
import numpy as np
import datetime





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

sum=0
for n in range(1,N+1):
    if n<K:
        sum+=1/N*((1/2)**math.ceil(math.log2(K/n)))
    else:
        sum+=1/N
print(sum)

Solution (Python):
import math

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

sum = 0

for i in range(1,n+1):
    if i < k :
        x = -(-math.log2(k/i)//1)
        sum += (1/n) * pow(0.5,x)
    else:
        sum += (1/n)

print(sum)

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

print(res)

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

Solution (Python):
n,k=map(int,input().split())
ans=0
for i in range(1,n+1):
  s=i
  a=1
  while s<k:
    a/=2
    s*=2
  ans+=a
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:
        r = -(-(math.log2(K) - math.log2(i))//1)
        ans += 0.5**r*(1/N)
    else:
        ans += 1/N
print(ans)

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

s=0
for i in range(1,n+1):
      c=0
      while k>i:
            i=i*2
            c+=1
      s+=(1/n)*((1/2)**c)
print(s)

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

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

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

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

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

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

N, K = [int(x) for x in input().strip().split()]
ans = 0
for n in range(1, N + 1):
  ans_ = 1 / N
  score = n
  while score < K:
    ans_ *= 1 / 2
    score *= 2
  ans += ans_
else:
  print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

def print_ans(N, K):
    """Test Case
    >>> print_ans(3, 10)
    0.145833333333
    >>> print_ans(100000, 5)
    0.999973749998
    """
    prob = Decimal(1 / N)
    b = Decimal(math.log2(K))
    ans = 0
    for i in range(1, N + 1):
        if i >= K:
            ans += 1
        else:
            k = Decimal(math.ceil(b - Decimal((math.log2(i)))))
            ans += Decimal(2 ** (-k) ) 
    print(Decimal(ans * prob).quantize(Decimal('0.000000000001'), rounding=ROUND_HALF_EVEN))



if __name__ == '__main__':
    N, K = map(int, input().rstrip().split())
    print_ans(N, K)

Solution (Python):
import math

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

answer = 0

for i in range(1, N+1):
    if K > i:
        answer += (1/N) * (1/2)**(math.ceil(math.log2(K/i)))
    else:
        answer += (1 / N) 
print(answer)

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

ans = 0

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

print(ans)

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

def ct(n):
  ct=0
  while n<k:
    n*=2
    ct+=1
  return ct

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

Solution (Python):

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

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

A=0
count=0
for i in range(1,N+1):
    j=i
    count=0
    while j<K:
        j=j*2
        
        count=count+1
    else:
        A=A+(1/N)*pow(0.5,count)
        
print(A)

Solution (Python):
N,K=map(int,input().split())
X1=0
x=1
while x<=N:
  times=0
  point=x
  while point<=K-1:
    point*=2
    times+=1
  X1+=0.5**times/N
  x+=1
print(X1)

Solution (Python):
import math
import decimal

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

sum = 0

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


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

print('{:.12f}'.format(sum))

Solution (Python):
import bisect
import math
N,K = map(int,input().split(' '))
two_list = [ 2**i for i in range(18)]

rate = 0
for i in range(1,N+1):
    threshold = math.ceil(K/i) 
    two_idx = bisect.bisect_left(two_list,threshold)
    rate += 1 / N / two_list[two_idx]
print(rate)

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

Solution (Python):

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

Solution (Python):



def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n, k = rli()
    ans = 0
    for i in range(1, n+1):
        m = i
        prob = 1.0
        while m < k:
            prob /= 2
            m *= 2
        ans += prob
        
    ans /= n
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
N,K = map(int,input().split())
ans = 0
for i in range(1,N+1):
    count = 0
    while i < K:
        i *= 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):
    tmp = 1 / n
    now = i
    while now < k:
        now *= 2
        tmp /= 2
    ans += tmp
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 K <= i: ans += 1 
    else:
        x = log2(K/i)
    
        ans += 2 ** -ceil(x)
    
print(1/N * ans)

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

Solution (Python):
N,K = map(int,input().split())
dice = list(range(1,N+1))
count = []
for i in dice:
    tmp = i
    t = 0
    while tmp < K:
        tmp *= 2
        t += 1
    count.append(t)
ans = []
for i in range(len(count)):
    ans.append(1/N*(1/2)**count[i])
print(sum(ans))

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

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

Solution (Python):
n, k = [int(i) for i in input().split()]
win = 0
for i in range(1, n + 1):
  for j in range(k):
    if i * 2 ** j >= k:
      win += 0.5 ** j / n
      break
print(win)

Solution (Python):
import math
n,k = map(int,input().split())
probability = [0]*(n+1)
for i in range(1,n+1):
    score = i

    if score>k:
        probability[i] = 1/n
        continue
    
    count = math.ceil(math.log(k/i,2))
    probability[i] = 1/n * (1/2)**count

print(sum(probability))

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

ans = 0
for i in range(1, N+1):
    if i >= K:
        ans += 1/N
    else:
        k = ((K-1)//i) + 1
        count = 0
        while(k/2**count > 1):
            count += 1

        ans += (1/N) * (1/2)**count
print(ans)

Solution (Python):
n,k=map(int,input().split())
ans=0
cnt=0
ans1=0
cnt1=1
for j in range(1,min(n+1,k)):
    cnt=j
    cnt1=1
    for i in range(k):
        if cnt>=k:
            ans+=cnt1
            break
        cnt*=2
        cnt1/=2
print((max((n-k+1),0)+ans)/n)

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

Solution (Python):
N,K = map(int,input().split())
p=0
for i in range(1,N+1):
  b=len(bin(int(K-1)//i))-2
  if i >= K:
    b=0
  p +=1/((2**b)*N)
print(p)

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

scores = [0] * (n + 1)
cnts = [0] * (n + 1)

for i in range(1, (n + 1), 1):
    scores[i] = i

    while True:
        if (k <= scores[i]):
            break

        scores[i] *= 2
        cnts[i] += 1

list = list(map(lambda x: (1 / 2) ** x, cnts))
print(sum(list[1:(n + 1)]) / n)

Solution (Python):
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines



























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

Solution (Python):
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines







import numpy as np



















def main():
	N, K = map(int, input().split())
	ans=0
	for i in range(1,N+1):
		x=max(0,np.ceil(np.log2(K/i)))
		ans+=2**(-x)
	print(ans/N)
	
	
	
	
	
	
if __name__ == '__main__':
	main()

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

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

for i in range(1,n+1):
    a=0
    while i*(2**a)<k:
        a+=1
    li.append((1/n)*(1/2**a))
    
print(sum(li))

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

def renzoku(count, i):
    if i >= k:
        return count
    else:
        i = i * 2
        count += 1
        return renzoku(count, i)

ans = 0
for i in range(1, n+1):    
    count = renzoku(0, i)
    prob = (1/n) * ((1/2) ** count)
    ans += prob
print(ans)

Solution (Python):
def p_c():
    n, k = map(int, input().split())
    ans = 0
    m = min(n, k - 1)
    for i in range(1, m + 1):
        x = 0
        while k > i << x:
            x += 1
        ans += (1 / n) * (1 / (1 << x))
    if m == k - 1:
        ans += (n - k + 1) / n

    print(ans)
    
p_c()