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())
a = []
for i in range(1,n+1):
    x = i
    for j in range(100001):
        x = x*2
        if x >= k:
            #print(j)
            a.append(1/n * (0.5**(j)))
            break
print(sum(a))

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = []
for i in range(1,n+1):
    x = i
    for j in range(1,100001):
        x += i*2
        if x >= k-i:
            #print(i)
            a.append(1/n * 0.5**(i+1))
            break
print(sum(a))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
#表で得点2倍、ウラで0
#0かKで終わり
cnt=0
ans=0
j=2
t=k
for i in range(min(n,k)):
    while t//j>=1:
        t=t//j
        cnt+=1 #kがある数j-1で割れる回数
    j+=1
    t=k
    ans+= 1/3*(0.5)**(cnt+1)
    cnt=0
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
#表で得点2倍、ウラで0
#0かKで終わり
cnt=0
ans=0
j=2
t=k
for i in range(min(n,k)):
    while t//j>=1:
        t=t//j
        cnt+=1 #kがある数j-1で割れる回数
    print(k,"//",j-1,cnt+1)
    j+=1
    t=k
    ans+= 1/3*(0.5)**(cnt+1)
    cnt=0
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
#表で得点2倍、ウラで0
#0かKで終わり
if n>k:
    n=k
cnt=0
ans=0
j=2
t=k
while t//j>=1:
    t//=j
    cnt+=1 #kがある数で割れる回数
    ans+= 1/3*(0.5)**(cnt+1)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n, k = map(int, input().split())
prob = 0
for i in range(1, min(n + 1, k)):
    t = math.ceil(math.log2(k / i))
    print(t)
    prob += 0.5 ** t
prob *= 1/ n
print(prob)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
l = [i+1 for i in range(a)]
sum = 0
cnt = 0

for i in l:
  cnt = 0
  while i <= b:
    i *= 2
    cnt += 1
  sum += 1/a*((0.5)**cnt)
print(sum)

Submission status: Wrong Answer

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

def n(x, n):
    return x * 2**(n-1)

ans =0

for i in range(1, min(N+1, K)):
    c = 0
    j = 1
    while n(i, j) < K:
        j += 1
        c += 1
    ans += (1.0/N)*0.5**c
print(ans if N<K else ans+(1.0-K/N))

Submission status: Wrong Answer

Solution code:
import math

def calc_omote(x, y):
    if y-x <= 0: return 0
    if (y-x)/x < 1: return 1
    return math.ceil(math.log2(y/x - 1))
    

n, k = map(int, input().split())
ans = 0
if n < k:
    for i in range(1,n+1):
        omote = calc_omote(i, k)
        #print(omote, end=' ')
        p = 1/(2**omote)
        ans += p/n
else:
    ans = 1
    for i in range(1, k+1):
        omote = calc_omote(i, k)
        #print(omote, end=' ')
        p = 1/(2**omote)
        ans -= p/n        
#sump /= n
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

dice = 1/n

ans = 0

for i in range(1,n+1):
    buf = int(math.log(k/i,2))+1
    if buf < 0:
        buf = 0
    ans += dice * (1/2) ** buf

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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


sum_v = 0

if n > k :
    j = k
    s = [0]*(k-1)
else:
    j = n + 1
    s = [0]*n
    
for i in range(1, j):
    s[i-1] = math.ceil(math.log2(k/i))
    sum_v += (1/2)**s[i-1]
    #print(i,s[i-1],sum_v)
    
if n - k >= 0: 
    p1 = (n-k+1)/n
else:
    p1 = 0
    
p2 = sum_v/n
print(p1 + p2)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

nx = np.arange(1, n+1)


ans = 0
ed = n
coin = 0

while (ed > 0):
    ct = 0
    for i in range(ed-1, -1, -1):
        if (nx[i] >= k):
            ct += 1
            ed = i
        else:
            break
    ans += ct*(1/2**(coin))

    print(nx)
    nx *= 2
    coin += 1

print(ans/n)

Submission status: Wrong Answer

Solution code:
N,K=map(int, input().split())
p=0
for num in range(1,N+1):
    if(num > K ):
        p=p+1/N
        continue
    i=1
    while True:
        if((num)*(2**i) > K ):
            p=p + 2**(-i)/N
            break
        i=i+1
print(str(p)[:14])

Submission status: Wrong Answer

Solution code:
N,K=map(int, input().split())
p=0
for num in range(N):
    if(num+1 > K ):
        p=p+1
        continue
    i=1
    while True:
        if((num+1)*(2**i) > K ):
            p=p + 2**(-i)
            break
        i=i+1
print(p/N)

Submission status: Wrong Answer

Solution code:
N,K=map(int, input().split())
p=[]
for num in range(N):
    i=1
    if(num+1 > K ):
        p.append(1/N)
        continue
    while True:
        if((num+1)*(2**i) > K ):
            p.append((1/N)*(1/(2**i)))
            break
        i=i+1
print(sum(p))

Submission status: Wrong Answer

Solution code:
N,K=map(int, input().split())
p=[]
for num in range(N):
  for i in range(500):
    if( (num+1)*(2**(i+1)) > K ):
      p.append((1/N)*(1/(2**(i+1))))
      break
print(sum(p))

Submission status: Wrong Answer

Solution code:
import math

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

tmp = 0
for n in range(1,N+1):
  tmp += 0.5**(max(int(math.log2(K/n))+1,0))/N
                 
print(tmp)

Submission status: Wrong Answer

Solution code:
nums = input().split()
N = int(nums[0])
K = int(nums[1])
totalProb = 0

for i in range(N):
    x = i + 1
    tempProb = 1/N

    while x < K:
        tempProb = tempProb / 2
        x = x * 2
        print(tempProb)

    totalProb += tempProb

print(totalProb)

Submission status: Wrong Answer

Solution code:
nums = input().split()
N = int(nums[0])
K = int(nums[1])
totalProb = 0

for i in range(N):
    x = i + 1
    tempProb = 1/N

    while x < K:
        tempProb = tempProb / 2
        x = x * 2
        print(tempProb)

    totalProb += tempProb

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

print(totalProb)

Submission status: Wrong Answer

Solution code:
nums = input().split()
N = int(nums[0])
K = int(nums[1])
totalProb = 0

for i in range(K):
    x = i + 1
    tempProb = 1/N

    while x < K:
        tempProb = tempProb / 2
        x = x * 2
        print(tempProb)

    totalProb += tempProb

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

print(totalProb)

Submission status: Wrong Answer

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

if n < k:
    res = 0.5 ** math.ceil(math.log(k / n, 2))
else:
    res = n - k + 1

pow2 = int(math.log(k, 2))
lst = [int(k / (1 << i)) for i in range(pow2, -1, -1)]

res += sum(0.5 ** (pow2 + 1 - bisect_left(lst, i)) for i in range(1, min(n, k)))
print(res / n)

Submission status: Wrong Answer

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

if n < k:
    res = 1
else:
    res = n - k + 1

pow2 = int(math.log(k, 2))
lst = [int(k / (1 << i)) for i in range(pow2, -1, -1)]

res += sum(0.5 ** (pow2 + 1 - bisect_left(lst, i)) for i in range(1, min(n, k)))
print(res / n)

Submission status: Wrong Answer

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

ans = 0.0
prob_coin = 0.0
n_div = 1

while True:
    lwr = math.ceil(k/(2**n_div))
    upr = math.floor(k/(2**(n_div-1)))
    if n_div==1:
        upr = k-1
    n_count = 0
    if (lwr <= n)&(n<=upr):
        n_count= n-lwr+1
    elif (n>=upr):
        n_count= upr - lwr +1
    
    if upr== 0:
        break
        
    tmp_prob = 0.0
    tmp_prob = 1/(2**n_div)*n_count
    prob_coin += tmp_prob
    n_div+=1
ans += (max((n-k+1),0)+prob_coin)/n
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

output = 0
for i in range(1, N+1):
    jousuu = math.ceil(math.log2(K / i))
    result = (1 / N) * (1 / (2 ** jousuu))
    # print(result)
    output += result
    # print(output)

print(output)

Submission status: Wrong Answer

Solution code:
import math

def resolve():
    import sys
    input = sys.stdin.readline
    
    N, K = map(int, input().split())

    def get_trynum(X, K):
        count = 0
        while X < K:
            X *= 2
            count += 1
        return count

    win_rate_total = 0
    for i in range(1, N+1):
        try_num = get_trynum(i, K)
        win_rate = 0.5 ** try_num 
        if i % 100 == 0:
            print("i", i, "try_num", try_num, "win_rate", win_rate)
        win_rate_total += win_rate * (1/N)
    
    print(win_rate_total)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
import math

def resolve():
    import sys
    input = sys.stdin.readline
    
    N, K = map(int, input().split())

    win_rate_total = 0
    for i in range(1, N+1):
        if i == 1:
            try_num = math.ceil(math.log(K, 2))
        else:
            try_num = math.ceil(math.log(K, i)) - 1
        win_rate = 0.5 ** try_num 
        win_rate_total += win_rate * (1/N)
    
    print(win_rate_total)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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


# 組み込み関数のlogを使うとたまに壊れる
def calc_multi(k, x):
    cnt = 0
    while x <= k:
        cnt += 1
        x *= 2
    return cnt


ans = 0
for i in range(1, n+1):
    ans += 0.5 ** calc_multi(k, i)
print(ans / n)

Submission status: Wrong Answer

Solution code:
import math                                                                                                                                                         
                                                                                                                                                                    
def ci(n,k):                                                                                                                                                        
    #p ci>k                                                                                                                                                         
    a = n-k+1                                                                                                                                                       
    if(a<0):                                                                                                                                                        
        return 0                                                                                                                                                    
    else:                                                                                                                                                           
        return float(a/n)                                                                                                                                           
                                                                                                                                                                    
def coin(n,k):                                                                                                                                                      
    a = k/n                                                                                                                                                         
    if(a<1):                                                                                                                                                        
        return 0                                                                                                                                                    
    else:                                                                                                                                                           
        m = math.log(a)/math.log(2)                                                                                                                                 
        #print(m)                                                                                                                                                   
        #print(int(m)+1)                                                                                                                                            
        return(int(m)+1)                                                                                                                                            
                                                                                                                                                                    
def p_coin(n):                                                                                                                                                      
    return math.pow(0.5, n)                                                                                                                                         
                                                                                                                                                                    
def sumP3(n,k):                                                                                                                                                     
    a = 0                                                                                                                                                           
    for i in range(1, k):                                                                                                                                           
        if i>n :                                                                                                                                                    
            break                                                                                                                                                   
        #print(i,k)                                                                                                                                                 
        #print(p_coin(coin(i,k)))                                                                                                                                   
        a = a + (1/N[0])*p_coin(coin(i,k))                                                                                                                          
    return a                                                                                                                                                        
                                                                                                                                                                    
N = input().split()                                                                                                                                                 
N = [int(i) for i in N]                                                                                                                                             
#print(N)                                                                                                                                                           
#print(ci(N[0], N[1]))                                                                                                                                              
p1 = ci(N[0], N[1])                                                                                                                                                 
p2 = 1-p1                                                                                                                                                           
p3 = sumP3(N[0], N[1])                                                                                                                                              
print('{:.10g}'.format(p1+p3))

Submission status: Wrong Answer

Solution code:
import math                                                                                                                                                         
                                                                                                                                                                    
def ci(n,k):                                                                                                                                                        
    #p ci>k                                                                                                                                                         
    a = n-k+1                                                                                                                                                       
    if(a<0):                                                                                                                                                        
        return 0                                                                                                                                                    
    else:                                                                                                                                                           
        return float(a/n)                                                                                                                                           
                                                                                                                                                                    
def coin(n,k):                                                                                                                                                      
    a = k/n                                                                                                                                                         
    if(a<1):                                                                                                                                                        
        return 0                                                                                                                                                    
    else:                                                                                                                                                           
        m = math.log(a)/math.log(2)                                                                                                                                 
        #print(m)                                                                                                                                                   
        #print(int(m)+1)                                                                                                                                            
        return(int(m)+1)                                                                                                                                            
                                                                                                                                                                    
def p_coin(n):                                                                                                                                                      
    return math.pow(0.5, n)                                                                                                                                         
                                                                                                                                                                    
def sumP3(n,k):                                                                                                                                                     
    a = 0                                                                                                                                                           
    for i in range(1, k):                                                                                                                                           
        if i>n :                                                                                                                                                    
            break                                                                                                                                                   
        #print(i,k)                                                                                                                                                 
        #print(p_coin(coin(i,k)))                                                                                                                                   
        a = a + (1/N[0])*p_coin(coin(i,k))                                                                                                                          
    return a                                                                                                                                                        
                                                                                                                                                                    
N = input().split()                                                                                                                                                 
N = [int(i) for i in N]                                                                                                                                             
#print(N)                                                                                                                                                           
#print(ci(N[0], N[1]))                                                                                                                                              
p1 = ci(N[0], N[1])                                                                                                                                                 
p2 = 1-p1                                                                                                                                                           
p3 = sumP3(N[0], N[1])                                                                                                                                              
print(p1+p3)

Submission status: Wrong Answer

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

pow2 = [2**i for i in range(30)]
#print(pow2[-1])
ans = 0

for i in range(1,N+1):
    for j in range(len(pow2)):
        if K < i*pow2[j]:
            #print(j)
            ans += 1/pow2[j]
            break
ans *= (1/N)
print(ans)

Submission status: Wrong Answer

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

pow2 = [2**i for i in range(30)]
#print(pow2[-1])
ans = 0

for i in range(1,N+1):
    for j in range(len(pow2)):
        if K < i*pow2[j]:
            print(j)
            ans += 1/pow2[j]
            break
ans *= (1/N)
print(ans)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
coin = [0]*n
while k > 1:
    for i in range(min(int(k-1/1e10),n)):
        coin[i] += 1
    k /= 2
ans = 0
print(coin)
for i in range(n):
    ans += 1 / (2**coin[i] * n)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import math
import sys
input = sys.stdin.readline


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

    if n == 1 and k == 1:
        print(0.5)
        return

    result = 0
    if n < k:
        for i in range(1, n + 1):
            x = int(math.log(k / i, 2)) + 1
            result += (1 / n) * (0.5 ** x)
    else:
        for i in range(1, k):
            x = int(math.log(k / i, 2)) + 1
            result += (1 / n) * (0.5 ** x)
        result += (n - k + 1) / n
    print(result)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import math
import sys
input = sys.stdin.readline


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

    result = 0
    if n < k:
        for i in range(1, n + 1):
            x = int(math.log(k / i, 2)) + 1
            result += (1 / n) * (0.5 ** x)
    else:
        for i in range(1, k):
            x = int(math.log(k / i, 2)) + 1
            result += (1 / n) * (0.5 ** x)
        result += (n - k + 1) / n
    print(result)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
n,k = map(int,input().split())
ans = 0
for i in range(1,n+1,1):
  temp = i
  count = 0
  while (temp <= k):
      temp *= 2
      count += 1
  #print("1/{} * (1/2)^{}".format(n,count))
  ans += min(1,(math.pow((1/2),count)))
print("{:1.9f}".format(ans/n))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

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

iniarray = np.arange(1,N+1)
mask1 = iniarray < K
mask2 = 1 - mask1
prob_array = 1/2**np.ceil(np.log2(float(K)/iniarray))
ans = (prob_array * mask1 + mask2).sum() / float(N)

print(ans)

Submission status: Wrong Answer

Solution code:
import os, sys, re, math

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

lk = math.log2(K)

p = 0
for i in range(1, N + 1):
    if i >= K:
        p += 1.0
    else:
        p += (0.5 ** (int(lk - math.log2(i) + 1)))

print(p / N)

Submission status: Wrong Answer

Solution code:
import math

n,k =  map(int,input().split())
lis = []
for i in range(n):
    if i+1 >= k:
        lis.append(0)
    else:
        lis.append(math.ceil(math.log2((k/(i+1)))))

print(lis)


ans = []
for i in range(n):
    ans.append(1/n * (1/2)**lis[i])

print(sum(ans))

Submission status: Wrong Answer

Solution code:
import math

n,k =  map(int,input().split())
lis = []
for i in range(n):
    lis.append(math.ceil(math.log2((k/(i+1)))))
#print(lis)


ans = []
for i in range(n):
    ans.append(1/n * (1/2)**lis[i])

print(sum(ans))

Submission status: Wrong Answer

Solution code:
import math

n,k =  map(int,input().split())
lis = []
for i in range(n):
    lis.append(math.ceil(math.log2((k/(i+1)))))
print(lis)


ans = []
for i in range(n):
    ans.append(1/n * (1/2)**lis[i])

print(sum(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
n,k=map(int,input().split())
kari=1
ctr=0
while kari<=k:
	kari*=2
	ctr+=1
num=0
acc=0
p=0
for i in range(ctr+1):
	if 10/(2**i)<n:
		num=math.ceil(n-(10/(2**i)))
		pro=num-acc
		acc=num
		p+=(pro/n)*(1/2)**i
print(p)

Submission status: Wrong Answer

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

m = np.ceil(np.log2(k/dice))
print(m)
for i in range(n):
    if m[i] <= 0:
        m[i:] = 0
        break
p = (0.5**m)/n
print(sum(p))

Submission status: Wrong Answer

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

m = np.ceil(np.log2(k/dice))
p = (0.5**m)/n
print(sum(p))

Submission status: Wrong Answer

Solution code:
from math import log2,ceil

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

c = 0
for i in range(1, N+1):
    a = K // i
    b = 1/N*pow(0.5, a)
    c += b
print(c)

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:
        ans += 1/N
    else:
        n = math.floor( math.log2( 10/i ))
        p = 1/N * (0.5**n)
        ans += p

print(ans)