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



Sample input:
3 10


Sample output:
0.145833333333

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
ans=0
if n==k:
    ans+=1
    c=0
    for i in range(1,n):
        order=0
        c+=i
        while i<k:
            i*=2
            order+=1
        ans+=(0.5)**(order)
        c=0
    print(ans/n)
    
    
    
elif n<k:
    c=0
    for i in range(1,n+1):
        order=0
        c+=i
        while i<k:
            i*=2
            order+=1
        ans+=(0.5)**(order)
        print(c,order)
        c=0
    print(ans/n)    
    
    
elif n>k:
    ans+=(n+1-k)
    c=0
    for i in range(1,k):
        order=0
        c+=i
        while i<k:
            i*=2
            order+=1
        ans+=(0.5)**(order)
        c=0
    print(ans/n)

Submission status: Wrong Answer

Solution code:
import math
import decimal
decimal.getcontext().prec = 10

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

ans = decimal.Decimal(0)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
ans=0.0
for i in range(N):
  X=0
  if(K==i+1):
    Y=0
  else:
    Y=K//(i+1)
  while(Y):
    Y=Y//2
    X+=1
  ans+=0.5**X
print(ans/N)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
ans=0.0
for i in range(N):
  if(i+1<K):
    X=0
    Y=K//(i+1)
    while(Y):
      Y=Y//2
      X+=1
    ans+=0.5**X/N
  else:
    ans+=1.0/N
print(ans)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
ans=0.0
for i in range(N):
  if(i+1<K):
    X=0
    Y=K//(i+1)
    while(Y):
      Y=Y//2
      X+=1
    ans+=0.5**X/N
  else:
    ans+=1/N
print(ans)

Submission status: Wrong Answer

Solution code:
n,k =map(int,input().split())
p=0
for score in range(2,n+1):
  q=1/n
  while 0< score <k:
    q=q/2
    score = score * 2
  p=p+q
print(p)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

l = []
for i in range(1, N+1):
    for j in range(K):
        if i * (2 ** j) > K:
            l.append(1/N * 1/(2**j))
            break
print(sum(l))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0
for val in range(1,n+1):
    #print(val,",",math.log2(k)-math.log2(val))
    x = math.ceil(math.log(k,2)-math.log(val,2))
    ans = ans + 1/n * (1/2)**x 
print(ans)

Submission status: Wrong Answer

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

answer = 0

for dice in range(1,N+1):
    count = 0
    point = dice
    while point < 10:
        point = point*2
        count = count + 1
    answer = answer + (1/N * 0.5**count)
    
print(answer)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
ans=0
for i in range(1,N+1):
    x=0

    while True:

        if K < i*(2**x):
            ans+= (1/N)*((1/2)**x)
            break

        x+=1
        
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
N,K = map(int, input().split())
if K == 1:
    print(1)
else:
    P = max(0,(N-(K-1))/N)
    t = 0
    print(P)
    for i in range(1,min(N+1,K)):
        foo = math.log2(K/i)
        x=math.ceil(foo)
        t+=(1/2)**x
    P+=t*(1/N)
    print(P)

Submission status: Wrong Answer

Solution code:
import math
N,K = map(int, input().split())
if K == 1:
    print(1)
else:
    P = max(0,(N-(K-1))/N)
    print(P)
    for i in range(1,min(N+1,K)):
        foo = math.log2(K/i)
        x=math.ceil(foo)
        P+=(1/N)*(1/2)**x
    print("{:9f}".format(P))

Submission status: Wrong Answer

Solution code:
import math
N,K = map(int, input().split())
if K == 1:
    print(1)
else:
    P = max(0,(N-(K-1))/N)
    print(P)
    for i in range(1,min(N+1,K)):
        foo = math.log2(K/i)
        x=math.ceil(foo)
        P+=(1/N)*(1/2)**x
    print(P)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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()

Submission status: Wrong Answer

Solution code:
from functools import reduce
# from operator import add, sub, mul, truediv, and_, or_
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()

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = 0
for i in range(1, n+1):
    c = 0
    while i <= k:
        i *= 2
        c += 1
    p += (1/n) * (2 ** -c)
print(round(p, 12))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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
		print(j)
		print(ans2)
		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
		print(j)
		print(ans2)
		ans=ans+ans2

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

Submission status: Wrong Answer

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

dict ={}

list = []

for i in range(n, 0,-1): # Nから１までのN個の”出目”のリストを作成
    list.append(i)
#print(list)

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

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

print(sum/n)

Submission status: Wrong Answer

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

dict ={}

list = []

for i in range(n, 0,-1): # Nから１までのN個の”出目”のリストを作成
    list.append(i)
#print(list)
sum = 0
count = 0
i = 0
while(i <= len(list)-1):
    if k // list[i]  <= 2 ** count:
        #print("list is", list[i])
        #print("count is", count)
        sum += 1 / (2 ** count)
        #print("sum is", sum)
        i += 1
    else:
        count += 1

sum = sum / n
print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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
    m -= a
  p *= 2

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

count = 0.

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math 

n,k = map(int,input().split())
ans = (n-k+1)/n if n-k > 0 else 0
for i in range(min(n,k-1)):
  if k%(i+1) ==0:
    ans +=  1/n * (0.5)**math.ceil(math.log2(k//(i+1)))
  else:
    ans += 1/n * (0.5)**math.ceil(math.log2(k/(i+1)))
  
print(ans)

Submission status: Wrong Answer

Solution code:
import math 

n,k = map(int,input().split())
ans = (n-k+1)/n if n-k > 0 else 0
for i in range(min(n,k-1)):
  ans += 1/n * (0.5)**math.ceil(math.log2(k/(i+1)))
  
print(ans)

Submission status: Wrong Answer

Solution code:
from decimal import Decimal
N,K=map(int,input().split())
ans = 0
for i in range(1,N+1):
    if i >=K:
        ans+=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))

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
win = 0
if N >= K:
    #サイコロを振っただけで勝ちが確定する確率
    win += (N-K+1)/N
    for i in range(1,K):
        #最初に出た目がi(1 <= i < K)の時のKを超える確率の和を求める
        j =0
        while i*(2**j) < K:
            #勝負に勝つのは最初に出た目iを2のj乗した時にKを超える時
            j +=1
            win += 1/((2**j)*N)
else:
    for i in range(1,N+1):
        #最初に出た目がi(1 <= i <= N )の時Kを超える確率の和を求める
        j = 0
        while i*(2**j) < K:
            #勝負に勝つのは最初に出た目iを2のj乗した時にKを超える時
            j +=1
            win += 1/((2**j)*N)

print(win)

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
win = 0
if N >= K:
    #サイコロを振っただけで勝ちが確定する確率
    win += (N-K+1)/N
    for i in range(1,K):
        #最初に出た目がi(1 <= i < K)の時のKを超える確率の和を求める
        j =0
        while i*(2**j) < K:
            #勝負に勝つのは最初に出た目iを2のj乗した時にKを超える時
            j +=1
            win += 1/((2**j)*N)
else:
    for i in range(1,N):
        #最初に出た目がi(1 <= i <= N )の時Kを超える確率の和を求める
        j = 0
        while i*(2**j) < K:
            #勝負に勝つのは最初に出た目iを2のj乗した時にKを超える時
            j +=1
            win += 1/((2**j)*N)

print(win)

Submission status: Wrong Answer

Solution code:
from math import log, ceil
 
n, k = map(int, input().split())
 
res = 0
for i in range(1, min(n+1, k)):
##    print(k-i, ceil(log(k//i, 2)))
    res += (0.5 ** ceil(log(k//i, 2)))
    
if n >= k:
    res += (n-k+1)
print('{:.9f}'.format(res/n))

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
value = 0
for i in range(1, n+1):
    if i <= k-1:
        for j in range(1, 5):
            if i * (2**j) >= k:
                value += 1/(n * (2**j))
                break
    else:
        value += 1/n
print("{:.12f}".format(value))

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
value = 0

for i in range(1, n+1):
    if i <= k-1:
        for j in range(1, 5):
            if i * 2**j >= k:
                value += 1/(n * (2**j))
                break
    else:
        value += 1/n
print(value)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
value = 0

for i in range(1, n+1):
    if i <= k-1:
        for j in range(1, 5):
            if i * 2**j >= k:
                value += (1/n) * (1/(2**j))
                break
    else:
        value += 1/n
print(value)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
value = 0

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
value = 0

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

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

result=0.0

for i in range(1,n+1):
  if i>=k:
    result+=1.0/n
  else:
    temp=k//i
    e=len(bin(temp))-2
    #print(i,e)
    if temp*2**(e-1)>=k:
      result+=1.0/n*(1.0/2)**(e-1)
    elif temp*2**e>=k:
      result+=1.0/n*(1.0/2)**e
    elif temp*2**(e+1)>=k:
      result+=1.0/n*(1.0/2)**(e+1)
 
print(result)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
ans = 0
n, k = map(int, input().split())
for i in range(1, n+1):
    count = 0
    while True:
        if i*(2**count) > k:
            break
        count += 1
    a = 1/n
    for i in range(count):
        a *= (0.5)
    ans += a
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
ans=0
n,k=map(int,input().split())
for i in range(1,n+1):
    count=0
    while True:
        if i*(2**count)>k:
            break
        count+=1
    ans+=1/(2**count)
print(ans/n)

Submission status: Wrong Answer

Solution code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

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

# まずコインを振る最低回数を特定
coint_count = 0
coin = N
while True:
    if coin > K:
        break

    coint_count += 1
    coin *= 2

#print(coint_count)

ans = 0
for i in range(N, 0, -1):
    ans += (1/N) * 0.5**coint_count
    coint_count += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import math
N,K=map(int,input().split())
m=0
for i in range(N):
  q=math.sqrt(K//(i+1))
  m+=(1/2)**math.ceil(q)
print(m/N)

Submission status: Wrong Answer

Solution code:
import math
N,K=map(int,input().split())
m=0
for i in range(N):
  q=math.sqrt(K//(i+1))
  if int(q)==q:
    m+=(1/N)*((0.5)**q)
  else:
    m+=(1/N)*((0.5)**(int(q)+1))
print(m)

Submission status: Wrong Answer

Solution code:
import math

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

P = 0

for i in range(1, N+1):
    if i < K:
        T = int(math.log2(K / i)) + 1
        P += 1/ N * 1 / (2 ** T)
    else:
        P += 1 / N
    
            
print(P)

Submission status: Wrong Answer

Solution code:
import math

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

P = 0

for i in range(1, N+1):
    T = int(math.log2(K / i)) + 1
    P += 1/ N * 1 / (2 ** T)
            
print(P)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
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(power_list)
print(sum)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
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]
#print(power_list)
print(sum/n0)

Submission status: Wrong Answer

Solution code:
import math

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
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 / i) // 1)+1) 
  print(katsu/N)
  exit()
else: 
  for i in range(1, K):
    katsu += 0.5 ** ((math.log2(K / i) // 1)+1) 
  for i in range(K, N+1):
    katsu += 1
  
  print(katsu/N)
  exit()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math

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

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

print(ans/N)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import numpy as np
n,k = map(int,input().split())
prob = 0

for i in range(1,n+1):
  if i >= k:
    prob += 1/n
    
  else:
    j = int(((np.log(k/i))/(np.log(2)))//1) + 1
    lnprob = -np.log(n) - j*np.log(2)
    prob += np.exp(lnprob)
print(prob)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import numpy as np
n,k = map(int,input().split())
prob = 0

for i in range(1,n+1):
  if i >= k:
    prob += (n-i+1)/n
    print(prob)
    exit()
  else:
    j = int(((np.log(k/i))/(np.log(2)))//1) + 1
    lnprob = -np.log(n) - j*np.log(2)
    prob += np.exp(lnprob)
print(prob)

Submission status: Wrong Answer

Solution code:
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((K/i)**0.5)
            P += (1/N) * (0.5**p)
        print(P)
    except:
        break

Submission status: Wrong Answer

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

preans = 0

for i in range(1, n + 1):
    if i >= k:
        preans += 1
    else:
        j = np.log2(k / i) // 1 + 1
        preans += 1 / (2 ** j)

ans = preans / n

print(ans)

Submission status: Wrong Answer

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

preans = 0

for i in range(1, n + 1):
    if i >= k:
        preans += 1
    else:
        j = (float(np.log2(k)) - float(np.log2(i))) // 1 + 1
        preans += 1 / (2 ** j)

ans = preans / n

print(ans)

Submission status: Wrong Answer

Solution code:
import math
nk=list(map(int,input().split()))
a=0
for i in range(1,nk[0]+1):
    p=math.ceil(math.log(nk[1]/i, 2))
    a+=1/(2**(p))
print(a/nk[0])

Submission status: Wrong Answer

Solution code:
from math import ceil, sqrt

n, k = map(int, input().split())
nn = range(1, n + 1)

answer = sum(map(lambda x: 0.5 ** ceil(sqrt(k / x)) / n if x < k else 1 / n, nn))
print(answer)

Submission status: Wrong Answer

Solution code:
from math import ceil, sqrt

n, k = map(int, input().split())
nn = range(1, n + 1)

answer = sum(map(lambda x: 0.5 ** ceil(sqrt(k / x)) / n if n < k else 1 / n, nn))
print(answer)

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
ans = 0
l = [2**i for i in range(15)]

for j in range(1, N+1):
    for k in l:
        if j*k >= K:
            ans += (1/N)*0.5**math.log2(k)
            break
print(ans)

Submission status: Wrong Answer

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

j = 0

while k > 2 ** j:
    j += 1

jl = [j]

for i in range(2, n+1):
    p = jl[i - 2]
    if k <= i:
        p = 0
    else:
        while k < i * (2**p):
            p -= 1
        p += 1
    jl.append(p)

ans = 0

for j in jl:
    ans += 2**(-j) / n
print(ans)

Submission status: Wrong Answer

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

j = 0

while k > 2 ** j:
    j += 1

jl = [j]

for i in range(2, n+1):
    p = jl[i - 2]
    if k <= i:
        p = 0
    else:
        while k < i * (2**p):
            p -= 1
        p += 1
    jl.append(p)

ans = 0

for j in jl:
    ans += 2**(-j)
print(ans/n)

Submission status: Wrong Answer

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

dk, mk = divmod(k, 2)

j = 1

if k == 1:
    j = 0

while dk > 0:
    dk = dk // 2
    j += 1

jl = [j]

for i in range(2, n+1):
    p = jl[i - 2]
    if k <= i:
        p = 0
    else:
        while k < i * (2**p):
            p -= 1
        p += 1
    jl.append(p)

ans = 0

for j in jl:
    ans += 2**(-j)
print(ans/n)

Submission status: Wrong Answer

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

dk, mk = divmod(k, 2)
j = 1
while dk > 0:
    dk = dk // 2
    j += 1

jl = [j]

for i in range(2, n+1):
    p = jl[i - 2]
    if k <= i:
        p = 0
    else:
        while k < i * (2**p):
            p -= 1
        p += 1
    jl.append(p)

ans = 0

for j in jl:
    ans += 2**(-j)
print(ans/n)

Submission status: Wrong Answer

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

import math
sums = 0
for i in range(1,N+1):
    num=int(math.log(K/i,2)+1)
#     if num>int(num):
#         num=int(num)+1
    if i>K-1:
        sums +=(1/N)
    else:
        sums += 1/(N * math.pow(2,num))

print(sums)

Submission status: Wrong Answer

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

import math
sums = 0
for i in range(1,N+1):
    num=int(math.log(K/i,2)+1)
#     if num>int(num):
#         num=int(num)+1
    if i>K-1:
        sums +=(1/N)
    else:
        sums += (1/N) * math.pow(1/2,num)

print(sums)

Submission status: Wrong Answer

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

import math
sums = 0
for i in range(1,N+1):
    num=int(math.log(K/i,2)+1)
#     if num>int(num):
#         num=int(num)+1
    if i>K-1:
        sums +=(1/N)
    else:
        sums += (1/N) * math.pow(1/2,num)
        print(i,num)

print(sums)

Submission status: Wrong Answer

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

import math
sums = 0
for i in range(1,N+1):
    num=int(math.log2(K/i)+1)
    if i>=K-1:
        sums +=(1/N)
    else:
        sums += (1/N) * (1/2)**num
print(sums)

Submission status: Wrong Answer

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

import math
sums = 0
for i in range(1,N+1):
    num=int(math.log2(K/i)+1)
    if i>K-1:
        sums +=(1/N)
    else:
        sums += (1/N) * (1/2)**num
print(sums)

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
ans = 0
if K <= N:
    ans += (1/N)*(N-K+1)
    dp = [0] + [1/N] * K
else:
    dp = [0] + [1/N] * N + [0] * (K-N)
for i in range(1,K):
    if i % 2 == 0:
        dp[i] += dp[i//2] * (1/2)
ans += sum(dp[K//2+1:K])*(1/2)
print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
ans = 0
if K <= N:
    ans += (1/N)*(N-K)
    dp = [0] + [1/N] * K
else:
    dp = [0] + [1/N] * N + [0] * (K-N)
for i in range(1,K):
    if i % 2 == 0:
        dp[i] += dp[i//2] * (1/2)
ans += sum(dp[K//2+1:K])*(1/2) + sum(dp[K:])
print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
if K <= N:
    dp = [0] + [1/N] * N
else:
    dp = [0] + [1/N] * N + [0] * (K-N)
for i in range(1,K):
    if i % 2 == 0:
        dp[i] += dp[i//2] * (1/2)
if K <= N:
    print(sum(dp[K//2+1:K])*(1/2) + sum(dp[K:]))
else:
    print(sum(dp[K//2 + 1:-1]) * (1/2) + dp[K])

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N,K = map(int, input().split())
ans = 0
for i in range(1,N+1):
	coin = 0
	point = i
	if K <= i:
		ans += 1
	else:
		while point <= K:
			point *= 2
			coin += 1
		ans += (0.5)**coin

print(ans/N)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N,K = map(int, input().split())
ans = 0
for i in range(1,N+1):
	tmp = 1/N
	point = i
	if K <= i:
		ans += 1/N
	else:
		while point <= K:
			point *= 2
			tmp /=2
		ans += tmp

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N,K = map(int, input().split())
ans = 0
if K == 1:
	print(1)
	exit()

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

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N,K = map(int, input().split())
ans = 0

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

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N,K = map(int, input().split())
ans = 0

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
ite = 0
for i in range(1, N+1):
    for j in range(10**5):
        if K < i*2**j:
            ite = j
            break

    ans += (1/N) * (1/2)**ite

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(1, n + 1):
    c = math.ceil(math.log(k / i, 2))
    res += (1 / n) * (0.5 ** c)

print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
pb = 0
 
for i in range(1, n):
  mul = 0
  
  while k > i * (2 ** mul):
    mul += 1
    
  pb += (0.5 ** mul) / n
print(pb)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
pb = 0
count = 0
if n >= k:
  pb += (n-k+1)/n
  count = k - 1
else:
  count = n

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

Submission status: Wrong Answer

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

p = 0
ans = 0

for i in range(N):
    t = 0
    p = i + 1
    temp = K
    while temp >= p * (2 ** t):
        t += 1
    ans += (0.5 ** t) / N
print(ans)

Submission status: Wrong Answer

Solution code:
import math

N,K = map(int,input().split())
NUM=[0]*N
bunsu=[0]*N

for i in range(N):
    NUM[i]=math.ceil(K/(i+1))
    total=i+1
    for j in range(0,2**10):
        total=(i+1)*(2**j)
        if(total>K):
            break

    bunsu[i]=1/(N*(2**j))

print(sum(bunsu))