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:


def main():
    n, k = map(int, input().split())
    ans = 0.0
    for t in range(1, n + 1):
        cnt = 0
        now = t
        per = 1.0
        while now < k - 1:
            per /= 2
            now *= 2
        ans += per / n
    print('{:.20}'.format(ans))
    pass


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:


def main():
    n, k = map(int, input().split())
    ans = 0.0
    for t in range(1, n + 1):
        cnt = 0
        now = t
        per = 1.0
        while now < k - 1:
            per /= 2
            now *= 2
        ans += per / n
    print(ans)
    pass


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

Submission status: Wrong Answer

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

s = 0
for i in range(n):
  t = float(k / (2 * (i+1)))
  s += (1/n) * ((1/2) ** t)
  
print(s)

Submission status: Wrong Answer

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

s = 0
for i in range(n+1):
  t = float(k / (2 * (i+1)))
  s += (1/n) * ((1/2) ** t)
  
print(s)

Submission status: Wrong Answer

Solution code:
def abc126c():
    import math
    n, k = map(int, input().split())
    ans = 0.0
    for i in range(1, min(k, n + 1)):
        v = math.ceil(math.log2(k / i))
        ans += math.pow(0.5, v)
    if n > k:
        ans += n - k + 1
    print((1 / n) * ans)


abc126c()

Submission status: Wrong Answer

Solution code:
def abc126c():
    import math
    n, k = map(int, input().split())
    ans = 0.0
    for i in range(1, min(k, n + 1)):
        v = math.ceil(math.log2(k / i))
        print(v)
        ans += math.pow(0.5, v)
    if n > k:
        ans += n - k + 1
    print((1 / n) * ans)


abc126c()

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
tmp = 1
num_cnt = 0
while K > tmp :
  tmp *= 2
  num_cnt +=1
nums_list = []
for i in range(1,N+1):
  for j in range(num_cnt+1):
    if i*(2**j) > K:
      nums_list.append((1/2)**j)
      break
print(sum(nums_list)*(1/N))

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
answer = 0
for i in range(1, K):
    if i > N:
        break
    x = math.ceil(math.log2(K/i))
    p = (1/2)**x
    print(x, p)
    answer += p


answer *= 1/N
print(answer)

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
answer = 0
for i in range(1, K):
    if i > N:
        break
    x = math.floor(math.log2(K/i))+1
    p = (1/2)**x
    print(x, p)
    answer += p


answer *= 1/N
print(answer)

Submission status: Wrong Answer

Solution code:
import math


def calc_val(N, a):
    Tlist = list(range(N))
    out = list(map(lambda t: 1/(2**(a[t]+1)), Tlist))
    output = sum(out)/N
    return output


def calc_a(K):
    nList = list(range(1, num[0]+1))
    result = list(map(lambda i: math.floor(math.log2(K)-math.log2(i)), nList))
    return result


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

answer = calc_val(num[0], calc_a(num[1]))
print(answer)

Submission status: Wrong Answer

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

n = float(1/N)

i = 1 
ans = 0

while (i < N+1):
  p = i
  count = 0
  while True:
    if (p > K):
      break
    else:
      p = p*2
      count += 1
      
  win = n * (0.5)**count
  ans = ans + win
  i += 1
  
print(ans)

Submission status: Wrong Answer

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

ans = 0
for i in range(1, K):
    if i > N:
        break
    x = np.ceil(np.log2(K/i))
    p = (1/2)**x
    print(x, p)
    # print(x, p)
    ans += p

ans *= 1/N

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

print("{:.10f}".format(ans))

Submission status: Wrong Answer

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


ans = 0
for i in range(1, K):
    if i > N:
        break
    x = np.ceil(np.log2(K/i))
    p = (1/N) * (0.5)**int(x)
    # print(x, p)
    ans += p

print("{:.10f}".format(ans))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from math import log2
import decimal

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

ans = 0

decimal.getcontext().prec = 12

for i in range(1, N+1):
    if i < K:
        power = -(-(log2(K) - log2(i))//1)
        prob = decimal.Decimal(1/((2**power) * N))
    else:
        prob = decimal.Decimal(1/N)

    #print(prob)
    ans = decimal.Decimal(ans + prob)

print(ans)

Submission status: Wrong Answer

Solution code:
from math import log2
import decimal

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

ans = 0

decimal.getcontext().prec = 12

for i in range(1, N+1):
    if i < K:
        power = -(-(log2(K) - log2(i))//1)
        prob = decimal.Decimal(1/((2**power) * N))
    else:
        prob = decimal.Decimal(1/N)

    print(prob)
    ans = decimal.Decimal(ans + prob)

print(ans)

Submission status: Wrong Answer

Solution code:
def LI():
    return list(map(int, input().split()))


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

    ans += x/N
print(ans)

Submission status: Wrong Answer

Solution code:
def LI():
    return list(map(int, input().split()))


N, K = LI()
ans = 0
for i in range(1, N+1):
    x = 1
    count = i
    while count <= K:
        count *= 2
        x *= 1/2
    ans += x/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):

    x = math.ceil((math.log(K) - math.log(i)) / math.log(2))

    if x < 1:
        x = 0

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

n, k = map(int, input().split())
log2 = math.log10( 2)
ans = 0
for i in range(1,n+1):
    temp = i
    cnt = 0
    if i >= k :
        ans += (1/n)*(n-i)
        print(ans)
        exit()
    while temp < k:
        cnt += 1
        temp *= 2
    ans += (1/n) * 0.5**cnt

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

print(ans)

Submission status: Wrong Answer

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

if N > K:
  M = K - 1
  p = 0
  q = 0
  for i in range(M,0,-1):
    while i*(2**q) < K:
      q += 1
    p += 0.5**q
  print(1 - p*(1/N))
else:
  p = 0
  q = 0
  for j in range(N,0,-1):
    while j*(2**q) < K:
      q += 1
    p += 0.5**q
  print(p*(1/N))

Submission status: Wrong Answer

Solution code:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n,k = LI()
    num = 0
    frac = 0
    while n * 2**num < k:
        num+=1
    frac += 1/2**num
    print(frac)

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

Submission status: Wrong Answer

Solution code:
import math
from fractions import Fraction


#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

n,k=input2()
flag=False
ans=0
for i in range(1,n+1):
	point=i
	if point>=k:
		ans+=Fraction(1,n)
	else:
		tmp=math.ceil(math.log2((k//point)))
		ans+=Fraction(1,n)*Fraction(1,2**tmp)
print(float(ans))

Submission status: Wrong Answer

Solution code:
import math
from fractions import Fraction

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())
  
n,k=input2()
flag=False
ans=0
for i in range(1,n+1):
	point=i
	if point>=k:
		flag=True
		ans+=Fraction(1,n)
		break
	tmp=math.ceil(math.log2((k//point)))
	ans+=Fraction(1,n)*Fraction(1,2**tmp)
print(float(ans))

Submission status: Wrong Answer

Solution code:
import math
N,K=map(int,input().split())
pro=0
if N==1 and K==1:
    print(1)
elif N>=K:
    pro+=(N-K+1)/N
    for k in range(1, K):
        r = math.ceil((K / k))
        pro += 0.5**r / N
    print(pro)

else:
    for k in range(1, N+1):
        r = math.ceil((K / k))
        pro += 0.5**r / N
    print(pro)

Submission status: Wrong Answer

Solution code:
import math
import decimal
N,K=map(int,input().split())
# x=1/N
x=decimal.Decimal(1)/decimal.Decimal(N)
count=0
lst=[]
for i in range(1,N+1):
    count=1
    j=i
    while j*2<K:
        count+=1
        j*=2
    lst.append(count)
    
    if count==1 and i*2>=K:
        break
ans=[]
# print(lst)
for i in range(len(lst)):
    cc=0
    # print(math.pow(1//2,lst[i]))
    cc=math.pow(x,1)*math.pow(decimal.Decimal(1)/decimal.Decimal(2),lst[i])
    ans.append(cc)
print(sum(ans))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
cnt=0
j=17
for i in range(1,n+1):
    if i>=k:
        cnt+=1
    else:
        while i*(2**j)>k:
            j-=1
        cnt+=1/2**(j+1)
print(format(cnt/n,'.12f'))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
cnt=0
j=17
for i in range(1,n+1):
    if i>=k:
        cnt+=1
    else:
        while i*(2**j)>k:
            j-=1
        cnt+=1/2**(j+1)
print(cnt/n)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math


ans = 0
N, K = map(int, input().split())
dp = [[0] * (2*K + 1) for _ in range(int(math.log2(K)) + 2)]
for i in range(1, N + 1):
    if i < 2*K + 1:
        dp[0][i] = 1 / N
    else:
        ans += 1 / N
for cnt in range(1, int(math.log2(K)) + 2):
    for now in range(1, 2*K + 1):
        if now % 2 == 0:
            dp[cnt][now] = dp[cnt - 1][now//2] * 0.5
    ans += sum(dp[cnt][K:])
#print(dp)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

p = 0
for i in range(1, N + 1):
    m = numpy.ceil(numpy.log2((K - 1) / i)) 
    p += 0.5 ** m
    
print(p / N)

Submission status: Wrong Answer

Solution code:
n,k = list(map(int,input().split()))
p = [] 

for i in range(1, n+1):
    tmp = i
    cnt=0
    while tmp<=k:
        tmp *=2
        cnt += 1 
    p.append((1/n)*(1/2)**cnt)
print(round(sum(p),12))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

n,k=map(int,input().split())
m = defaultdict(int)
shift = 0
d = n
while d > 0:
	if (d << shift) > k:
		m[shift] += 1
		d -= 1
	else:
		shift += 1
p = 0
for k,v in m.items():
	p += v / n / (1 << k)
print(p)

Submission status: Wrong Answer

Solution code:
import math
n, k = map(int, input().split())
ans = 0.0
if n >= k:
  ans += (n-k+1)/n
  
for i in range(1, min(n+1, k)):
  ans+= (1/2)**(math.floor(math.log2(k/i))+1)
print(ans)

Submission status: Wrong Answer

Solution code:
from decimal import Decimal 
n, k = map(int, input().split())
if n >= k:
    print(Decimal((n - k + 1) / n))
else:
    a = n

    count = 0
    p = 0
    while n < k:
        n *= 2
        count += 1
    p += Decimal(1 / a * (1/2) ** count)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split());result=0
for i in range(1,n+1):
  t=i
  count=0
  while t <= k:
    t*=2
    count+=1
  result+=1/n*(1/2)**count
print(result)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-07-29 15:03:43 +0900
# LastModified: 2020-07-29 15:29:30 +0900
#


from math import log


def main():
    n, k = map(int, input().split())
    ans = 0
    for i in range(1, min(n+1, k)):
        tmp_ans = 1/n
        if ((log(k)-log(i))/log(2)).is_integer():
            s = int((log(k)-log(i))/log(2))+1
        else:
            s = int((log(k)-log(i))/log(2))+1
        tmp_ans *= (1/2)**s
        ans += tmp_ans
    if n >= k:
        ans += (n-k+1)/n
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-07-29 15:03:43 +0900
# LastModified: 2020-07-29 15:25:02 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from math import log


def main():
    n, k = map(int, input().split())
    ans = 0
    for i in range(1, min(n+1, k)):
        tmp_ans = 1/n
        if ((log(k)-log(i))/log(2)).is_integer():
            s = int((log(k)-log(i))/log(2))
        else:
            s = int((log(k)-log(i))/log(2))+1
        tmp_ans *= (1/2)**s
        ans += tmp_ans
    if n >= k:
        ans += (n-k+1)/n
    print(ans)



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-07-29 15:03:43 +0900
# LastModified: 2020-07-29 15:22:24 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from math import log


def main():
    n, k = map(int, input().split())
    ans = 0
    score = 0
    for i in range(1, min(n+1,k)):
        score = i
        tmp_ans = 1/n
        if ((log(k)-log(i))/log(2)).is_integer():
            s = int((log(k)-log(i))/log(2))
        else:
            s = int((log(k)-log(i))/log(2))+1
        tmp_ans *= (1/2)**s
        ans += tmp_ans
    if n >= k:
        ans += (n-k+1)/n
    print(ans)



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-07-29 15:03:43 +0900
# LastModified: 2020-07-29 15:19:53 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from math import log


def main():
    n, k = map(int, input().split())
    ans = 0
    score = 0
    for i in range(1, min(n+1,k)):
        score = i
        tmp_ans = 1/n
        s = int((log(k)-log(i))/log(2))+1
        tmp_ans *= (1/2)**s
        ans += tmp_ans
    if n >= k:
        ans += (n-k+1)/n
    print(ans)



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import log2,ceil
n,k=[int(s) for s in input().split()]

sum=0
for t in range(1,n+1):
    sum+=1/(2**ceil(log2(k/t)))
print(sum/n)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
SUM=0
for i in range(1,N+1):
  if i<K:
    n_trial = (K//i).bit_length()
    tmp = 1/(2**n_trial)
  else:
    tmp = 1
  SUM += tmp
print(1/N*SUM)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
SUM=0
for i in range(1,N+1):
  if i<K:
    n_trial = (K//i).bit_length()
    tmp = 1/(2**n_trial)
  else:
    tmp = 1
  SUM += tmp
print(SUM)

Submission status: Wrong Answer

Solution code:
# abc126_c.py
# https://atcoder.jp/contests/abc126/tasks/abc126_c

# C - Dice and Coin /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 300点

# 問題文
# すぬけ君は 1〜 N の整数が等確率で出る N面サイコロと表と裏が等確率で出るコインを持っています。
# すぬけ君は、このサイコロとコインを使って今から次のようなゲームをします。
#     まず、サイコロを 1回振り、出た目を現在の得点とする。
#     得点が 1以上 K−1 以下である限り、すぬけ君はコインを振り続ける。表が出たら得点は 2 倍になり、裏が出たら得点は 0になる。
#     得点が 0になった、もしくは K 以上になった時点でゲームが終了する。このとき、得点が K 以上である場合すぬけ君の勝ち、 0である場合すぬけ君の負けである。
# Nと Kが与えられるので、このゲームですぬけ君が勝つ確率を求めてください。

# 制約
#     1≤N≤105
#     1≤K≤105
#     入力はすべて整数

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N K


# 出力
# すぬけ君が勝つ確率を出力せよ。絶対誤差または相対誤差が 10^−9以下のとき正解とみなされる。

# 入力例 1
# 3 10

# 出力例 1
# 0.145833333333

#     サイコロの出た目が 1のとき、得点が 10 以上になるためには、 4 回コインを振って 4 連続で表が出る必要があります。この確率は、 1/3×(1/2)4=1/48です。
#     サイコロの出た目が 2のとき、得点が 10 以上になるためには、 3 回コインを振って 3 連続で表が出る必要があります。この確率は、 1/3×(1/2)3=1/24です。
#     サイコロの出た目が 3のとき、得点が 10 以上になるためには、 2 回コインを振って 2 連続で表が出る必要があります。この確率は、 1/3×(1/2)2=1/12です。

# よって、すぬけ君が勝つ確率は、 148+124+112=748≃0.1458333333です。

# 入力例 2
# 100000 5

# 出力例 2
# 0.999973749998


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    # N = int(lines[0])
    N, K = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(6):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(Q):
    #     valueses.append(list(map(int, lines[i+1].split())))

    result = 0.0

    for i in range(1, N+1):
        if i*(2**0) >= K:
            rate = 0.5**0
        elif i*(2**1) >= K:
            rate = 0.5**1
        elif i*(2**2) >= K:
            rate = 0.5**2
        elif i*(2**3) >= K:
            rate = 0.5**3
        elif i*(2**4) >= K:
            rate = 0.5**4
        elif i*(2**5) >= K:
            rate = 0.5**5
        elif i*(2**6) >= K:
            rate = 0.5**6
        elif i*(2**7) >= K:
            rate = 0.5**7
        elif i*(2**8) >= K:
            rate = 0.5**8
        elif i*(2**9) >= K:
            rate = 0.5**9
        elif i*(2**10) >= K:
            rate = 0.5**10
        elif i*(2**11) >= K:
            rate = 0.5**11
        elif i*(2**12) >= K:
            rate = 0.5**12
        elif i*(2**13) >= K:
            rate = 0.5**13
        elif i*(2**14) >= K:
            rate = 0.5**14
        else:
            # ここには来ない
            rate = 0
        result += rate/N

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['3 10']
        lines_export = [0.145833333333]
    if pattern == 2:
        lines_input = ['100000 5']
        lines_export = [0.999973749998]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
A=list(map(int,input().split()))
N=A[0]
K=A[1]
p=0
for i in range(1,N+1):
    count=0
    while i<=K-1:
        i=i*2
        count=count+1
    p=p+(1/2)**(count)
print(p)
print(p/N)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if n > k:
    ans = (n-k+1)
else:
    ans = 0

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

ans /= n
print(ans)

Submission status: Wrong Answer

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

if n > k:
    ans = (n-k+1)
else:
    ans = 0

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

Submission status: Wrong Answer

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

#まず、nがk以上だった場合、勝ちになるので、① n-k+1/n
#k-1 => 得点 >1の場合、コインを投げ、表を出し続け、k以上に出す確率
#k-1=> k/2（切り上げ）に関しては、１回表を出すから 1/2 (1乗）
#k/2(切り捨て）からk/4（切り上げ）に関しては、1/2の二乗
#print(int(math.log2(n))+1)
if n>=k:
  ans=n-k+1
  for i in range(1, k):
    ans+=(1/2)**(int(math.log2(k/i))+1)
else:
  ans=0
  for i in range(1, n+1):
    ans+=(1/2)**(int(math.log2(k/i))+1)
print(ans/n)

Submission status: Wrong Answer

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

#まず、nがk以上だった場合、勝ちになるので、① n-k+1/n
#k-1 => 得点 >1の場合、コインを投げ、表を出し続け、k以上に出す確率
#k-1=> k/2（切り上げ）に関しては、１回表を出すから 1/2 (1乗）
#k/2(切り捨て）からk/4（切り上げ）に関しては、1/2の二乗
#print(int(math.log2(n))+1)
if n>k:
  ans=n-k+1
  for i in range(1, k):
    ans+=(1/2)**(int(math.log2(k/i))+1)
else:
  ans=0
  for i in range(1, n+1):
    ans+=(1/2)**(int(math.log2(k/i))+1)
print(ans/n)

Submission status: Wrong Answer

Solution code:
from fractions import Fraction
N , K = list(map(int,input().split()))
denom_list = []
Z=0


def detame_keisan( N , K , i ):
    kijun = K
    score = i
    count = 0
    
    while score < kijun:
        count += 1
        score = ( score *  2 )
        
        print(count)
    return N * (2 ** count)

for i in range( 1,N+1 ):
    X = detame_keisan( N , K , i)
    denom_list.append( X )

for item in denom_list:
    #Z += 1/item
    Z += Fraction(1, item)
#print( Z)
print( float( Z.numerator / Z.denominator ))

Submission status: Wrong Answer

Solution code:
from fractions import Fraction
N , K = list(map(int,input().split()))
denom_list = []
Z=0


def detame_keisan( N , K , i ):
    kijun = 10
    score = i
    count = 0
    
    while score < kijun:
        count += 1
        score = ( score *  2 )
        
        print(count)
    return N * (2 ** count)

for i in range( 1,N+1 ):
    X = detame_keisan( N , K , i)
    denom_list.append( X )

for item in denom_list:
    #Z += 1/item
    Z += Fraction(1, item)
print( float( Z.numerator / Z.denominator ))

Submission status: Wrong Answer

Solution code:
from fractions import Fraction
N , K = list(map(int,input().split()))
denom_list = []
Z=0


def detame_keisan( N , K , i ):
    kijun = 10
    score = i
    count = 0
    
    while score < kijun:
        count += 1
        score = ( score *  2 )
        
        print(count)
    return N * (2 ** count)

for i in range( 1,N+1 ):
    X = detame_keisan( N , K , i)
    denom_list.append( X )

for item in denom_list:
    #Z += 1/item
    Z += Fraction(1, item)
print( Z.numerator / Z.denominator)

Submission status: Wrong Answer

Solution code:
from fractions import Fraction
N , K = list(map(int,input().split()))
denom_list = []
Z=0


def detame_keisan( N , K , i ):
    kijun = 10
    score = i
    count = 0
    
    while score < kijun:
        count += 1
        score = ( score *  2 )
        
        print(count)
    return N * (2 ** count)

for i in range( 1,N+1 ):
    X = detame_keisan( N , K , i)
    denom_list.append( X )

for item in denom_list:
    Z += 1/item
print( Z )

Submission status: Wrong Answer

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


Z=0
result_a=0
number=[]

for i in range(1,N+1):
    J=0
    kijun_tokuten=0
    kijun_tokuten = K - i#これで9点、これを超えればいい
    now_tokuten=i
    while now_tokuten <= kijun_tokuten:
        now_tokuten = now_tokuten * 2
        J += 1
    Y =  (2 ** J) * N#Yはそのターンの確率
    Z=Y
    number.append(Z)
    
for j in range(N):
    number[j] = Fraction(1,number[j])

for k in range(N):
    result_a += number[k]

result_b = float(result_a)
print(result_b)
X=1/Z

Submission status: Wrong Answer

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


Z=0

for i in range(1,N+1):
    J=0
    kijun_tokuten=0
    kijun_tokuten = K - i#これで9点、これを超えればいい
    now_tokuten=i
    while now_tokuten <= kijun_tokuten:
        now_tokuten = now_tokuten * 2
        J += 1
    Y =  (2 ** J) * N#Yはそのターンの確率
    Z=Z+Y
X=1/Z
print(X)

Submission status: Wrong Answer

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

ans = Decimal(0)
for i in range(N):
  if i+1 < K:
    tmp = math.log2(K//(i+1))
    if tmp > int(tmp):
      tmp = int(tmp)+1
    else:
      tmp = int(tmp)
    ans += Decimal(1/(2**(tmp)))
  else:
    ans += 1
ans *= Decimal((1/N))
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
for i in range(N):
  if i+1 < K:
    tmp = math.log2(K//(i+1))
    if tmp > int(tmp):
      tmp = int(tmp)+1
    ans += 1/(2**(tmp))
  else:
    ans += 1
ans *= (1/N)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
if k==1:
  print(1)
  exit()
e=[0]*(k)
e[-2]=1
now=k
while int(now)!=1:
  if now/2==now//2 and int(now)!=2:
    now=now/2
    e[int(now)-2]+=1
  elif int(now)==2:
    e[0]=e[1]+1
    now=now/2
  else:
    now=now/2
    e[int(now)-1]+=1
e_=[]
for i in range(k):
  if i==0:
    e_.append(e[k-1-i])
  else:
    e_.append(e[k-1-i]+e_[-1])       
ans=0    
if n<k:
  for i in range(n):
    t=1
    for _ in range(e_[k-1-i]):
      t/=2
    ans+=t  
  print(ans/n) 
else:
  for i in range(k):
    t=1
    for _ in range(e_[k-1-i]):
      t/=2  
    ans+=t  
  ans=ans/n
  ans+=(n-k)/n
  print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
if k==1:
  print(1)
  exit()
e=[0]*(k)
e[-2]=1
now=k
while int(now)!=1:
  if now%2==0 and int(now)!=2:
    now=now/2
    e[int(now)-2]+=1
  elif int(now)==2:
    now+=-1
    e[int(now)-1]+=1
  else:
    now=now/2
    e[int(now)-1]+=1
e_=[]
for i in range(k):
  if i==0:
    e_.append(e[k-1-i])
  else:
    e_.append(e[k-1-i]+e_[-1])       
ans=0    
if n<k:
  for i in range(n):
    t=1
    for _ in range(e_[k-1-i]):
      t/=2
    ans+=t  
  print(ans/n) 
else:
  for i in range(k):
    t=1
    for _ in range(e_[k-1-i]):
      t/=2  
    ans+=t  
  ans=ans/n
  ans+=(n-k)/n
  print(ans)