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())

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = 0;

from numpy import log2
for i in range(n):
  if i >= k:
    ans += 1/n
    continue
  dice_num = int(log2(k/(i+1))) + 1
  ans += ((1/2)**dice_num)/n

print(ans)

Submission status: Wrong Answer

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

ans = 0;

from numpy import log2
for i in range(n):
  if i >= k:
    ans += 1
    continue
  dice_num = int(log2(k/(i+1))) + 1
  ans += (1/2)**dice_num

print(ans/n)

Submission status: Wrong Answer

Solution code:
from math import log2

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

sum_prob = 0
for init_num in range(1, N + 1):
    if init_num < K:
        n_trial_lower = round(log2(K / init_num) + 1.0)
        prob = 1 / N * (0.5**n_trial_lower)
    else:
        prob = 1 / N
    sum_prob += prob

print(sum_prob)

Submission status: Wrong Answer

Solution code:
from math import log2

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

sum_prob = 0
for init_num in range(1, N + 1):
    if init_num < K:
        n_trial_lower = int(log2(K / init_num) + 1)
        prob = 1 / N * (0.5**n_trial_lower)
    else:
        prob = 1 / N
    sum_prob += prob

print(sum_prob)

Submission status: Wrong Answer

Solution code:
from math import log2
N, K = 100000, 5
p = 0.0
if N >= K:
    p1 = (N-K+1)/N
    p2 = 1.0
    p += p1
    temp = 0.0
    for i in range(1, K): # 1 to K-1
        n = int(log2(K-1)-log2(i))+1
        temp += (0.5)**n
    p2 *= temp*(1/N)
    p += p2
else:
    temp = 0
    for i in range(1, N+1): # 1 to N
        n = int(log2(K-1)-log2(i))+1
        temp += (0.5)**n
    p = temp*(1.0/N)
print(p)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A=N
total=0
count=1
flag=0
if N>=K:
   total=(N-K+1)/N
   print(total)
   N=K-1
if N<K:
    while(flag==0):
        if(K/2<1):
            flag=1
        if K%2==1:
            K = K//2+1
        elif K%2==0:
            K = K // 2
        if N>=K:
            
            total += (N-K+1)*1/(A*2**count)
            N=N-(N-K+1)
            
        count += 1
    print(total)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A=N
total=0
count=1
flag=0
if N>K:
   total=(N-K)/N
   print(total)
   N=K-1
if N<K:
    while(flag==0):
        if(K/2<1):
            flag=1
        if K%2==1:
            K = K//2+1
        elif K%2==0:
            K = K // 2
        if N>=K:
            
            total += (N-K+1)*1/(A*2**count)
            N=N-(N-K+1)
            
        count += 1
    print(total)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A=N
total=0
count=1
flag=0
if N>K:
   total=(N-K)/N
   print(total)
   N=K-1
if N<K:
    while(flag==0):
        if(K/2<1):
            flag=1
        if K%2==1:
            K = K//2+1
        elif K%2==0:
            K = K // 2
        if N>=K:
            print(K,N,count)
            total += (N-K+1)*1/(A*2**count)
            N=N-(N-K+1)
            print(total)
        count += 1
    print(total)

Submission status: Wrong Answer

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

prob=0
for i in range(1,N+1):
  prob += 1/N*math.pow(1/2,int(math.log2(K/i))+1)

print(prob)

Submission status: Wrong Answer

Solution code:
import math

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

print(ans)

Submission status: Wrong Answer

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

def log2(n):
    res = 0
    while n >= 1:
        n /= 2
        res += 1
    return res

def ceil(n): # ceiling関数
    if n > int(n):
        return(int(n)+1)
    else:
        return(int(n))

a = []
for i in range(1,N+1):
    k = ceil(log2(K/i))
    if i < K:
        a.append(k)
    else:
        a.append(0)
m = max(a)
s = sum([2**(m-a[i]) for i in range(len(a))])
print(s/(N*(2**m)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def ans(count, num):
    
    prop = (1/2)**(count)
    prop = num*prop
    return prop

def answer(n, K):
    prop = float(0)
    count = 1
    while(True):
        i = 2**count
        if n >= K/i:
            if int(10*(K/i)) % 10 == 0:
                num = n - int(K/i) + 1
            else:
                num = n - int(K/i)
            n -= num
            prop += ans(count, num)
        count += 1
        if K/i <= 1:
            break
    return prop
    

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


prop = float(0)
if N > K:
    prop += (N-K+1)
    prop += answer(K-1, K)
    prop = format(prop/N, '.11f')
    print(prop)
else:
    print(format((1/N)*answer(N, K)), '.11f')

Submission status: Wrong Answer

Solution code:
def ans(count, num):
    
    prop = (1/2)**(count)
    prop = num*prop
    return prop

def answer(n, K):
    prop = float(0)
    count = 1
    while(True):
        i = 2**count
        if n >= K/i:
            if int(10*(K/i)) % 10 == 0:
                num = n - int(K/i) + 1
            else:
                num = n - int(K/i)
            n -= num
            prop += ans(count, num)
        count += 1
        if K/i <= 1:
            break
    return prop
    

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


prop = float(0)
if N > K:
    prop += (N-K+1)
    prop += answer(K-1, K)
    prop = prop/N
    print(prop)
else:
    print((1/N)*answer(N, K))

Submission status: Wrong Answer

Solution code:
#C
import numpy as np
n, k = list(map(int, input().split()))
ndewaru = 0
for p in range(n) :
    if p+1 < k :
        kata = np.floor(np.log2((p+1)/k))
        ndewaru += 2**kata
        print(kata)
    else :
        ndewaru += 1
print(ndewaru/n)

Submission status: Wrong Answer

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

percentage = 0

for appear in range(1, N + 1):
	i = 0
	while  K / (2 * appear) > i:
		i += 1
	percentage += (1 / N) * (1/2) ** i
	
print(percentage)

Submission status: Wrong Answer

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

percentage = 0

for appear in range(1, N + 1):
	i = 0
	while  K / (2 * appear) > i:
		i += 1
	percentage += (1/2) ** i
	
print(percentage)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
p = [0] * N
p[0] = len(bin(K)) - 2
if 2 ** p[0] >= K:
    p[0] = p[0] - 1
for i in range(N - 1):
    if 2 ** p[i] * (i + 2) >= 2 * K:
        p[i + 1] = p[i] - 1
    else:
        p[i + 1] = p[i]
    if p[i + 1] == 0:
        break
ans = float(0)
for n in range(1, N + 1):
    ans += 1 / N * ((1/2) ** p[n-1])
print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
p = [0] * N
p[0] = len(bin(K)) - 2
for i in range(N - 1):
    p[i + 1] = p[i]
    if 2 ** p[i + 1] * (i + 2) >= 2 * K:
        p[i + 1] -= 1
    if p[i + 1] == 0:
        break
ans = float(0)
for n in range(1, N + 1):
    ans += 1 / N * (0.5 ** p[n-1])
print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
p = [0] * N
p[0] = len(bin(K)) - 2
for i in range(N - 1):
    p[i + 1] = p[i]
    if 2 ** p[i + 1] * (i + 2) > 2 * K:
        p[i + 1] -= 1
ans = float(0)
for n in range(1, N + 1):
    if n >= K:
        ans += 1 / N
    elif n * 2 >= K:
        ans += 1 / N * 0.5
    else:
        ans += 1 / N * (0.5 ** p[n-1])
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
print(math.log2(11))

Submission status: Wrong Answer

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

for s in range(1,N+1):
    p = int(math.log2(K/s)) + 1
    if K>s:
        out += (1/N)*((1/2)**p)
    else:
        out += 1/N

print(out)

Submission status: Wrong Answer

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

probs = []
for i in range(1, N+1):
    n = 1
    while i * 2 ** n < K:
        n += 1

    p = (1/N) * (1/2)**n
    probs.append(p)

print(sum(probs))

Submission status: Wrong Answer

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

ans = 0.000000
for i in range(1, N+1):
    if i >= K:
        ans = float((ans + 1))/float(2)
    else:
        loop = 0
        tmp = i
        while True:
            tmp *= 2
            loop += 1
            if tmp > K:
                break
        ans += float(1)/float(N) * float(1)/float(2)**float(loop)
print(ans/N)

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*0.5**c
print(p)

Submission status: Wrong Answer

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

s1  = float(0)
for i1 in range(n1):
    r1 = (i1 + 1)
    c1 = 1
    if n2 <= r1:
        s1 += (1/n1)
        continue

    while True:
        r1 *= 2
        c1 = c1 * (1/2)
        if n2 <= r1:
            s1 += ((1/n1)*c1)
            break

print(str(s1)[0:14])

Submission status: Wrong Answer

Solution code:
def coin(i,k):
    count = 0
    while i <= k:
        i = i * 2
        count += 1
    return count

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


for i in range(1,n+1):
    x = coin(i, k)
    sum += (1/n) * ((0.5) ** x)

print(sum)

Submission status: Wrong Answer

Solution code:
import math
N,K = map(int,input().split())
List = []
for i in range(1,N+1):
    if i>=K:
        List.append(0)
    else:
        tmp = i
        count = 0
        while(tmp<K):
            tmp = tmp*2
            count+=1
        List.append(count) 
        
ans = [0]*N
ans[0] = 0.5**List[0]/N
for i in range(1,N):
    if List[i-1]==List[i]:
        ans[i] = ans[i-1]
    else:
        ans[i] = (2**(List[i-1]-List[i]))*ans[i-1]#直前の答えに減った2の累乗だけ掛け算してあげる．
print(sum(ans))
print(List[0:20])
print(ans[0:20])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
n, k = [int(v) for v in input().split()]

#1-N => iが出たとする
#i * 2^(ai-1) < k <= i * 2^(ai) となる aiを求める
#ai = math.ceil(math.log(k/i, 2)) 
#勝率は(1/2)^ai
#勝率を求めるには i について平均をとればよい
pi = []
for i in range(1,n+1):
  ai = math.ceil(math.log(k/i, 2))
  pi.append( ((1/2)**ai) / n )
print(sum(pi))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
kli = [k]
kch = k
while True:
  if kch == 1:
    break
  kch = (kch-1)//2 + 1
  kli.append(kch)
kli.reverse()
qli = []
def f(x):
  if x > 0:
    return x
  else:
    return 0
le = len(kli)
for i in range(le-1):
  p = min(n+1,kli[i+1])
  q = p - kli[i]
  qli.append(f(q))
qli.append(f(n+1-kli[-1]))
qli.reverse()
b = 1
son = 0
for i in range(le):
  son += b * qli[i]
  b /= 2
print(kli,qli,son/n)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
a = []
b = []
tmp = k
now = 0
while True:
  a += [now]
  b += [tmp]
  if tmp==1:break
  now += 1
  tmp = tmp - tmp//2
b.reverse()
if n+1 < k:
  j = 0
  while True:
    if b[j] >= n+1:
      b[j] = n+1
      b[j+1:] = []
      break
    j += 1
else:
  b[-1] = n+1
l = len(b)
print(l)
mother = (2**(len(a)-1))*n
son = 0
for i in range(l-1):
  print(b[i+1],b[i])
  son += (2**(a[i]))*(b[i+1]-b[i])
print(son/mother)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
a = []
b = []
tmp = k
now = 0
while True:
  a += [now]
  b += [tmp]
  if tmp==1:break
  now += 1
  tmp = tmp - tmp//2
b.reverse()
if n+1 < k:
  j = 0
  while True:
    if b[j] >= n+1:
      b[j] = n+1
      b[j+1:] = []
      break
    j += 1
else:
  b[-1] = n+1
l = len(b)
print(l)
mother = (2**(len(a)-1))*n
son = 0
for i in range(l-1):
  print(b[i+1],b[i])
  son += (2**(a[i]))*(b[i+1]-b[i])
print(son,mother,son/mother)

Submission status: Wrong Answer

Solution code:
import math
N,K = map(int,input().split())
r = 0
m = math.floor(K / N) + 1
for n in range(m,1,-1):
	r += round((1 / N ) * ((1 / 2) ** n), 12)
    
print(r)

Submission status: Wrong Answer

Solution code:
import math
N,K = map(int,input().split())
r = 0
m = math.floor(K / N) + 1
for n in range(m,1,-1):
	r += (1 / N ) * ((1 / 2) ** n)
    
print(r)

Submission status: Wrong Answer

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

prob = 0
for now_ in range(1, N+1):
  times = 0
  if now_ > K:
    prob += (1/N) * (N - now_)
    break
    
  while K > now_:
    now_ *= 2
    times += 1
  prob += (1/N) * (1/2)**times
print(prob)

Submission status: Wrong Answer

Solution code:
import math
N,K = map(int,input().split())
List = []
for i in range(1,N+1):
    if i>K:
        List.append(1)
    else:
        tmp = K//i
        List.append(math.ceil(math.log2(tmp)))
ans = [0]*N
ans[0] = 0.5**List[0]/N
for i in range(1,N):
    if List[i-1]==List[i]:
        ans[i] = ans[i-1]
    else:
        ans[i] = 2**(List[i-1]-List[i])*ans[i-1]
print(sum(ans))

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
cnt = 0
prob = 0
score = 0
for i in range(1, min(n+1,k)):
        score = i
        while True:
                print(score)
                score = score*2
                cnt += 1
                print('score', score)
                print('cnt', cnt)
                if score >= k:
                        break
        prob += 1/n * (1/2)**(cnt)
        print(prob)
        cnt = 0
if n >= k:
        ans = prob + (n-k+1)/n
else:
        ans = prob
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):
    ite = math.ceil((math.log2(k)-math.log2(i))/math.log2(2))
    ans+=pow(0.5,ite)/n
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N = 3
K = 10
r = 0
for n in range(1,N+1):
	r += 1 / (n * 2**(math.floor(K / n) + 1))
print(r)

Submission status: Wrong Answer

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

s=0

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

Submission status: Wrong Answer

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

p = 0

for n0 in range(1, N+1):
    n = n0
    for i in range(0, 1000):
        if n > K:
            break
        n *= 2
    p += 1/(N* (2 **i))

print(p)

Submission status: Wrong Answer

Solution code:
def kakeru(i):
    for a in range(K+1):
        if i*2**a > K:
            return a

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

for i in range(1,N+1):
    x = kakeru(i) if i < K else 0
    #print(x)
    pulas = (1/N)*((0.5)**x) if x > 0 else 1/N
    result += pulas
    #print(pulas)

print(result)

Submission status: Wrong Answer

Solution code:
def kakeru(i):
    for a in range(K):
        if i*2**a > K:
            return a

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

for i in range(1,N+1):
    x = kakeru(i) if i < K else 0
    #print(x)
    pulas = (1/N)*((0.5)**x) if x > 0 else 1/N
    result += pulas
    #print(pulas)

print(result)

Submission status: Wrong Answer

Solution code:
import math

def kakeru(i):
    for a in range(K):
        if i*2**a > K:
            return a

N, K = map(int, input().split())
#a = math.ceil(math.log(K, 2))
#print(a)
result = 0
#print(a)


for i in range(1,N+1):
    x = kakeru(i) if i < K else 0
    #print(x)
    pulas = (1/N)*((0.5)**x) if x > 0 else 1/N
    result += pulas
    #print(pulas)

print(result)

"""
count = 0

while K > N:
    K /= 2
    count += 1

result = 0.0
for i in range(K):
    result += (1./float(N))*((1./2.)**float((count + i)))

#print(K)
#print(count)
print(result+a)
print("%f" %result)
"""

Submission status: Wrong Answer

Solution code:
import math

def kakeru(i):
    for a in range(K):
        if i*2**a > K:
            return a

N, K = map(int, input().split())
#a = math.ceil(math.log(K, 2))
#print(a)
result = 0
#print(a)


for i in range(1,N+1):
    x = kakeru(i) if i < K else 0
    print(x)
    pulas = (1/N)*((0.5)**x) if x > 0 else 1/N
    result += pulas
    #print(pulas)

print(result)

"""
count = 0

while K > N:
    K /= 2
    count += 1

result = 0.0
for i in range(K):
    result += (1./float(N))*((1./2.)**float((count + i)))

#print(K)
#print(count)
print(result+a)
print("%f" %result)
"""

Submission status: Wrong Answer

Solution code:
import math

def kakeru(i):
    for a in range(1,K):
        if i*2**a > K:
            return a

N, K = map(int, input().split())
#a = math.ceil(math.log(K, 2))
#print(a)
result = 0
#print(a)


for i in range(1,N):
    x = kakeru(i)
    #print(x)
    pulas = (1/N)*((0.5)**x) if x > 1 else 1/N
    result += pulas
    #print(pulas)

print(result)

"""
count = 0

while K > N:
    K /= 2
    count += 1

result = 0.0
for i in range(K):
    result += (1./float(N))*((1./2.)**float((count + i)))

#print(K)
#print(count)
print(result+a)
print("%f" %result)
"""

Submission status: Wrong Answer

Solution code:
import math
N, K = map(int, input().split())
#a = (N-K)/N if N > K else 0
#print(a)
#for i in N:
a = math.ceil(math.log(K, 2))
#print(a)
result = 0

for i in range(N):
    pulas = (1/N)*((0.5)**(a-i)) if (a-i) > 0 else 1/N
    result += pulas

print(result)

"""
count = 0

while K > N:
    K /= 2
    count += 1

result = 0.0
for i in range(K):
    result += (1./float(N))*((1./2.)**float((count + i)))

#print(K)
#print(count)
print(result+a)
print("%f" %result)
"""

Submission status: Wrong Answer

Solution code:
import math
N, K = map(int, input().split())
#a = (N-K)/N if N > K else 0
#print(a)
#for i in N:
a = math.ceil(math.log(K, 2))
print(a)
result = 0

for i in range(N):
    pulas = (1/N)*((0.5)**(a-i)) if (a-i) > 0 else 1/N
    result += pulas

print(result)

"""
count = 0

while K > N:
    K /= 2
    count += 1

result = 0.0
for i in range(K):
    result += (1./float(N))*((1./2.)**float((count + i)))

#print(K)
#print(count)
print(result+a)
print("%f" %result)
"""

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
a = (N-K)/N if N > K else 0
#print(a)

count = 0
while K > N:
    K /= 2
    count += 1

result = 0
for i in range(N):
    result += (1/N)*((1/2)**(count + i))

#print(K)
#print(count)
print(result+a)

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

Solution code:
import sys
import math

def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    
    l = []
    for i in range(N):
        j = i + 1
        cnt = 1
        while True:
            j = j * 2
            
            if j >= K:
                l.append(cnt)
                break
            else:
                cnt = cnt + 1
    ans = []
    for c in l:
        cnt = 0
        if c > 1:
            ans.append(1 / (N * 2 ** c))
        else:
            ans.append(1 / N)
    else:
        if N > K:
            ans.pop()
    
    print(sum(ans))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math

def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    
    l = []
    for i in range(N):
        j = i + 1
        cnt = 1
        while True:
            j = j * 2
            
            if j >= K:
                l.append(cnt)
                break
            else:
                cnt = cnt + 1
    ans = []
    for c in l:
        cnt = 0
        if c > 1:
            ans.append(1 / (N * 2 ** c))
        else:
            ans.append(1 / N)
    else:
        if c == 1:
            ans.pop()
    
    print(sum(ans))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math

def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    
    l = []
    for i in range(N):
        j = i + 1
        cnt = 1
        while True:
            j = j * 2
            
            if j >= K:
                l.append(cnt)
                break
            else:
                cnt = cnt + 1
                
    ans = [1 / (N * 2 ** c) if c > 1 else 1 / N for c in l]
    print(sum(ans))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

import math
x=0

for i in range(n):
    if i+1<k:
        e = math.ceil(math.log2(k//(i+1)))
        
        x += 1/(n*(2**e))
    else:
        x+= 1/n
print(x)

Submission status: Wrong Answer

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

import math
x=0

for i in range(n):
    if i+1<k:
        e = math.floor(math.log2(k//(i+1)))+1
        
        x += 1/(n*(2**e))
    else:
        x+= 1/n
print(x)

Submission status: Wrong Answer

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

import math
import decimal
decimal.getcontext().prec = 19

x = decimal.Decimal(0)
y = decimal.Decimal(0)


for i in range(n):
    if i<k:
        e = math.ceil(math.log2(k//(i+1)))
        
        x += decimal.Decimal(1/(n*(2**e)))
    else:
        y += 1
print(x+decimal.Decimal(y/n))

Submission status: Wrong Answer

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

import math
import decimal
decimal.getcontext().prec = 19

x = decimal.Decimal(0)
y = decimal.Decimal(0)


for i in range(n):
    if i<k:
        e = math.floor(math.log2(k//(i+1)))+1
        
        x += decimal.Decimal(1/(n*(2**e)))
    else:
        y += 1
print(x+decimal.Decimal(y/n))

Submission status: Wrong Answer

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

import math
import decimal
decimal.getcontext().prec = 16

x = decimal.Decimal(0)
y = decimal.Decimal(0)


for i in range(n):
    if i+1<k:
        e = math.floor(math.log2(k//(i+1)))+1
        
        x += decimal.Decimal(1/(n*(2**e)))
    else:
        y += 1
print(x+decimal.Decimal(y/n))

Submission status: Wrong Answer

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

import math
import decimal
decimal.getcontext().prec = 16

x = decimal.Decimal(0)

for i in range(n):
    if i+1<k:
        e = math.floor(math.log2(k//(i+1)))+1
        
        x += decimal.Decimal(1/(n*(2**e)))
    else:
        x += decimal.Decimal(1/n)
print(x)

Submission status: Wrong Answer

Solution code:
from math import log2

def calProb(dice, K):
    time = log2(K)
    i = 1
    prob = 0
    base = 1/dice
    while i < time:
        temp = base
        now = i
        while now < K:
            now *= 2
            temp *= 0.5
        prob += temp
        i+=1
    i-=1
    return prob + ((dice - i)/dice)


inputs = list(map(float,input().split(' ')))[:2]
dice = inputs[0]
K = inputs[1]
probabilty = calProb(dice, K)
print(probabilty)

Submission status: Wrong Answer

Solution code:
from math import log2

def calProb(dice, K):
    time = log2(K)
    i = 1
    prob = 0
    base = 1/dice
    while i < time:
        i += 1
        prob += base * pow(0.5,i)
    i-=1
    return prob + ((dice - i)/dice)


inputs = list(map(float,input().split(' ')))[:2]
dice = inputs[0]
K = inputs[1]
probabilty = calProb(dice, K)
print(probabilty)

Submission status: Wrong Answer

Solution code:
from math import log2

def calProb(dice, K):
    time = log2(K)
    i = 1
    prob = 0
    base = 1/dice
    while i < time:
        i += 1
        prob += base * pow(0.5,i)
    return prob + ((dice - i)/dice)
    

inputs = list(map(float,input().split(' ')))[:2]
dice = inputs[0]
K = inputs[1]
probabilty = calProb(dice, K)
print(probabilty)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 09:53:12 2019

@author: Owner
"""
import numpy as np
import sys
import collections
import scipy.misc
import math
from operator import itemgetter
import itertools
import copy
import bisect

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


"""
N, X = map(int, input().split())

x = list(map(int, input().split()))

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())

# 多次元配列の宣言（あとでintにすること。）（タプルにすること。）
dp = np.zeros((N+1, 4,4,4))
    
all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break
# 累積和
add = 1 # 問題によって決まる
res = 0
sums = [0]*(len(nums)+1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]
for i in range(0, len(nums), 2):
    left = i
    right = min(i+add, len(nums))
    tmp = sums[right] - sums[left]
    res = max(tmp, res)

#２分探索
li, ri = bisect.bisect_left(p_ac, l[i]-1), bisect.bisect_right(p_ac, r[i]-1)    

#ソート関数
org_list = [3, 1, 4, 5, 2]
new_list = sorted(org_list)
print(org_list)
print(new_list)
# [3, 1, 4, 5, 2]
# [1, 2, 3, 4, 5]

#Distance Transformation
    for h in range(0,H):
        for w in range(0,W):
            if h == 0 and w == 0:
                pass
            elif h == 0:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h-1][W-w]+1)
            elif w == 0:   
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1)
            else:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1, D[H-h-1][W-w]+1, D[H-h][W-w]+2)
            d_max = max(D[H-h-1][W-w-1], d_max)

"""
N, K = list(map(int, input().split()))
def main():
    p = 0.
    if K < N:
        p += float(N-K+1)/float(N)
    if K<=N:
        r = K
    else:
        r = N+1
    for n in range(1,r):
        i = 1         
        while n*2**i<K:
            i+=1
        p += 1./float(N)*(1./2.)**(float(i)) 
            
    print(p)
                
                
                
            
            
                

    
if __name__ == '__main__':
    main()