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

print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
M = 0
def coin(x):
  k = 1
  while k <= x:
    k *= 2
  return 1/k
for i in range(N):
  M += coin(K/(i + 1))
  
print(M / N)

Submission status: Wrong Answer

Solution code:

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

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

print(prob)

Submission status: Wrong Answer

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

# more than K or K

res = []

for i in range(1, N + 1):
    # when dice is i
    x = 1
    while i < K:
        x = x * 0.5
        i = i * 2
    l = (1/3) * x
    res.append(l)

print(sum(res))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K = map(int, open(0).read().split())
a = 0
for i in range(1, N+1):
    j = 0
    s = i * 2**j
    while s < 10:
        j += 1
        s = i * 2**j

    a += (1/N)*(1/2)**j

print(a)

Submission status: Wrong Answer

Solution code:
from math import log2
n, k = map(int, input().split())
probability = max((n-k+1)/n, 0)
log_k = int(log2(k))
lower_bound = 1
upper_bound = min(n+1, k+1)

for i in range(lower_bound, upper_bound):
    log_i = int(log2(i))
    power = log_k - log_i

    if i*2**power < k: power += 1
    probability += (1/n) * ((1/2) ** power)

print(round(probability, 9))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

def nextpow2(n):
    m_f = np.log2(n)
    m_i = np.ceil(m_f)
    return int(np.log2(2**m_i))
l=[((1/2)**(nextpow2(K/i)))/N for i in range(1,N+1)]
print('{:.10f}'.format(sum(l)))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
ans=0	
for i in range(1,n+1): #出る目[1,n]について調べる
	l=1
	while i*2**l<k:
		l+=1
	ans+=1/n*(1/2)**l
print('{:.10f}'.format(ans)) #小数点以下8桁表示

Submission status: Wrong Answer

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

two_count_list = np.array([])
for i in range(1, n+1):
    two_count =0
    score = i
    while score <= k-1:
        score *= 2
        two_count += 1

    two_count_list = np.append(two_count_list, two_count)    

print(two_count_list)
print((1/n) * ((1/2) ** two_count_list).sum())

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
ln = []
for _ in range(1,n+1):
    for i in range(k):
        if _ *(2**i) <= k and _ * (2**(i + 1)) > k:
            ln.append(0.5 ** (i + 1)) 
print(sum(ln)/n)

Submission status: Wrong Answer

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

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

print(ret)

Submission status: Wrong Answer

Solution code:
import math

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

def bunbo(N):
    return 1/N

def n_calc(n, K):
    A = math.log10(K/n)/math.log10(2)
    A = A + 0.9
    A = int(A)
    return A

def calc(N, K):
    result = 0
    const = 1/N
    for i in range(1, N+1):
      c = n_calc(i, K)
      if c < 0:
        c = 0
      result += (const * ((1/2)**c))
    return result
  
print(calc(N, K))

Submission status: Wrong Answer

Solution code:
import math

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

def bunbo(N):
    return 1/N

def n_calc(n, K):
    A = math.log10(K/n)/math.log10(2)
    A = A + 0.99
    A = int(A)
    return A

def calc(N, K):
    result = 0
    const = 1/N
    for i in range(1, N+1):
      c = n_calc(i, K)
      if c < 0:
        c = 0
      result += (const * ((1/2)**c))
    return result
  
print(calc(N, K))

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+=1/n
    else:
        x = i
        cnt = 0
        while x < k:
            x *= 2
            cnt += 1
        print(i,cnt)
        ans += 1/(n*(2**cnt))
print(ans)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
if(a>b):
  l=[x+1 for x in range(b-1)]
elif(b>=a):
  l=[x+1 for x in range(a)]
print(l)
cnt=0
t=[]
for i in l:
  cnt=0
  n=b/i
  while(n>=1):
    n=n//2
    cnt+=1
    print(cnt)
  t.append((0.5**cnt)*(1/a))
print(t)
if(b>=a):
  print(sum(t))
elif(a>b):
  print(1-sum(t))

Submission status: Wrong Answer

Solution code:
import math

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import math

N,K = [int(i) for i in input().split()]
P = 0
for n in range(1,N+1) :
    if n < K :
        A = int(math.log10(K/n) / math.log10(2)) + 1
        pn = (1/N) * (1/2) ** A
        P += pn
    else :
        P += (1/N)
print('{:.10f}'.format(P))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import math

N,K = [int(i) for i in input().split()]
P = 0
for n in range(1,N+1) :
    if n < K :
        A = int(math.log10(K/n) / math.log10(2)) + 1
        pn = (1/N) * (1/2) ** A
        P += pn
    else :
        P += (1/N)
print(P)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
tmp = float(0)
print (tmp)
if N<K:
	for i in range (1,N+1):
		#print(i)
		count = 1
		while(1):
			#print (count)
			if i*2**count < K:
				count += 1
			else:
				break
		tmp += float(1/N)*float(1/(2**count))
else:
	for i in range (1,K):
		#print(i)
		count = 1
		while(1):
			#print (count)
			if i*2**count < K:
				count += 1
			else:
				break
		tmp += float(1/N)*float(1/(2**count))
	tmp += float(N-K+1)*float(1/N)
print(tmp)

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

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

if K <= N:
	ans = (N-K+1)/N
	end = K
else:
	ans = 0
	end = N+1
for i in range(1, end):
	ans += (1/N) * (1/2)**math.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):
    cnt = 0
    while i*pow(2,cnt) < k:
        cnt += 1
    ans = ((1/2)**cnt)/n
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from fractions import Fraction

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

print(float(rate)) if rate is not None else print(0)

Submission status: Wrong Answer

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

print(rate)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N, K = (int(x) for x in input().split())

num = np.log2(K)
num = int(np.ceil(num)) # for文のループ数

k = [int(np.ceil(K/(2**i))) for i in range(num+1)]

count = 0
multi = 2
probablity = 0
if N < K:
    while N*multi < K:
        count += 1
        multi = multi*2
    probablity = (N - k[count+1] + 1)/N
    if N*multi == K:
        probablity = probablity/(2**(count))
    else:
        probablity = probablity/(2**(count+1))
else:
    probablity = (N - k[count] + 1)/N
    probablity = probablity/(2**(count))
for i in range(len(k)-1):
    if i < count+1:
        continue
    else:
        probablity += (k[i] - k[i+1])/(N*(2**(i+1)))
print(probablity)

Submission status: Wrong Answer

Solution code:
import numpy as np

N, K = (int(x) for x in input().split())

num = np.log2(K)
num = int(np.ceil(num)) # for文のループ数

k = [int(np.ceil(K/(2**i))) for i in range(num+1)]

count = 0
multi = 2
probablity = 0
if N < K:
    while N*multi < K:
        count += 1
        multi = multi*2
    probablity = (N - k[count+1] + 1)/N
    probablity = probablity/(2**(count+1))
else:
    probablity = (N - k[count] + 1)/N
    probablity = probablity/(2**(count))
for i in range(len(k)-1):
    if i < count+1:
        continue
    else:
        probablity += (k[i] - k[i+1])/(N*(2**(i+1)))
print(probablity)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split()) 
 #複数文字の入力
ans = 0

for i in range(1,n+1):
  j=0 
  #カウンター設置
  while i<k:
    i*=2
    j+=1
  ans=1/2**j
print("{:.12}".format(ans/n))

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split()) 
 #複数文字の入力
ans = 0

for i in range(1,n+1):
  j=0 
  #カウンター設置
  while i<k:
    i*=2
    j+=1
  ans=1/2**j
print(ans/n)

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
ans = 0
for n in range(N):
    win_count = int(max(0, math.log2(K/(n+1))+1))
    ans += (1/N) * ((1/2)**win_count)
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0
for n in range(1,N+1):
  a = math.log2(10/n)
  a = math.ceil(a)
  ans+=(0.5**a)/N
  
print(ans)

Submission status: Wrong Answer

Solution code:
import math
import heapq
import sys
from collections import Counter
import numpy as np
import datetime

#N,K=map(int, input[0].split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
#x=list(map(int, input[1].split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
#s = [input() for i in range(3)]

N,K=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき

a=1/N*((1/2)**math.ceil(math.log2(K)))
sum=a
for n in range(2,N+1):
    a*=2
    sum+=a

print(sum)

Submission status: Wrong Answer

Solution code:
import math
import heapq
import sys
from collections import Counter
import numpy as np
import datetime

#N,K=map(int, input[0].split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
#x=list(map(int, input[1].split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
#s = [input() for i in range(3)]

N,K=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき

a=1/3*((1/2)**math.ceil(math.log2(K)))
sum=a
for n in range(2,N+1):
    a*=2
    sum+=a

print(sum)

Submission status: Wrong Answer

Solution code:
import math

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

sum = 0

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

print(sum)

Submission status: Wrong Answer

Solution code:
import math

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

sum = 0

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

print(sum)

Submission status: Wrong Answer

Solution code:
import math

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

sum = 0

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

print(sum)

Submission status: Wrong Answer

Solution code:
import math
from fractions import Fraction

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

sum = 0

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

print(sum)

Submission status: Wrong Answer

Solution code:
import math

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

sum = 0

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

print(sum)

Submission status: Wrong Answer

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

print(res)

Submission status: Wrong Answer

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

print(res)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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+=1/n
    else:
        y=1
        while True:
            x=i*2**y
            if x<=k:
                y+=1
            else:
                break
        ans+=1/n*(1/2)**y
print(ans)

Submission status: Wrong Answer

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

# リスト化
x = [k//i for i in range(1, n+1)]
y = []
for i in x:
    cnt = 0
    while i != 0:
        i //= 2
        cnt += 1
    y.append(cnt)

ans = 0
for i in y:
    ans += 1/n * 0.5 ** i

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

A=0
count=0
for i in range(1,N+1):
    j=i
    count=0
    for c in range(100000):
        j=j*2
        #print(j)
        count=count+1
        if j>K:
            A=A+(1/N)*pow(0.5,count)
            break
print(A)

Submission status: Wrong Answer

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

A=0
count=0
for i in range(1,N+1):
    j=i
    print(i)
    count=0
    for c in range(100000):
        j=j*2
        #print(j)
        count=count+1
        if j>K:
            A=A+(1/N)*pow(0.5,count)
            break
print(A)

Submission status: Wrong Answer

Solution code:
import math
import decimal

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

sum = 0

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


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

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

Submission status: Wrong Answer

Solution code:
import math

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

s = 2
# hituyouna omote nokazu
ans = 0
for i in range(1, N + 1):
    if i < K:
        o = int(math.log2(K / i) + 1)
        p = 0.5**o
        ans += p
    else:
        ans += 1
print(ans / N)

Submission status: Wrong Answer

Solution code:
import math
N, K = map(int, input().split())
ans = 0
end = math.ceil(math.log2(K))
start = math.ceil(math.log2(N))

for i in range(start, end+1):
    ans += (1/N)*((1/2)**i)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
n,k = map(int,input().split())
probability = [0]*(n+1)
for i in range(1,n+1):
    score = i
    if score>k:
        break
        
    count = math.ceil(math.log(k/i,2))
    probability[i] = 1/n * (1/2)**count

print(sum(probability))

Submission status: Wrong Answer

Solution code:
import math
n,k = map(int,input().split())
probability = [0]*(n+1)
for i in range(1,n+1):
    score = i
    if score>k:
        break
    #print(i)
    count = math.ceil(math.log(k/i,2))
    #print('count='+str(count))
    probability[i] = 1/n * (1/2)**count
    #print('probability='+str(probability[i]))
print(sum(probability))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

p = 0
for i in range(1, n+1):
    if i >= k:
        tmp = (n**-1)
    else:
        if math.log2(k//i) - int(math.log2(k//i)) > 0.999999999999999 == True:
            tmp = (n**-1)*(0.5)**int(math.log2(k//i))
        else:
            tmp = (n**-1)*(0.5)**int(math.log2(k//i) + 1)
    p+=tmp

print(p)

Submission status: Wrong Answer

Solution code:
import math

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

p = 0
for i in range(1, n+1):
    if i >= k:
        tmp = (n**-1)
    else:
        if isinstance(math.log2(k//i), int) == True:
            tmp = (n**-1)*(0.5)**int(math.log2(k//i))
        else:
            tmp = (n**-1)*(0.5)**int(math.log2(k//i) + 1)
    p+=tmp

print(p)

Submission status: Wrong Answer

Solution code:
import math

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

p = 0
for i in range(1, n+1):
    if i >= k:
        tmp = (n**-1)
    else:
        tmp = (n**-1)*(0.5)**int(math.log2(k//i) + 1)
    p+=tmp

print(p)

Submission status: Wrong Answer

Solution code:
import math
n,k=map(int,input().split())
i=1
sum=0.0
for i in range(1,n+1):
    cnt=k/i
    temp=1/n
    # cznt=i
    # 
    # while cnt < k:
    #     cnt*=2
    #     m+=1
    m=math.log2(cnt)
    m=m//1
    m+=1
    if i < k:
        sum+=temp * (1/2)**m
    else:
        sum+=temp
    # print(1/n * (1/2)**m)
print(sum)

Submission status: Wrong Answer

Solution code:
import math
n,k=map(int,input().split())
i=1
sum=0.0
for i in range(1,n+1):
    # cnt=k/i
    temp=1/n
    cnt=i
    m=0
    while cnt <= k:
        cnt*=2
        m+=1
    # m=math.log2(cnt)
    # m=m//1
    # m+=1
    # if i <= k:
    sum+=temp * (1/2)**m
    # print(1/n * (1/2)**m)
print(sum)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
import math
 #qは０点になる場合の数
if N>=K:
  q=(N-K+1)*(1/N)
  for i in range(1,K):
    if (K//i)%2!=0:
      q+=(1/N)*((1/2)**(i*int(math.log(K/i,2))+1))
    else:
      q+=(1/N)*((1/2)**(int(math.log(K/i,2))))
else:
  q=0
  for i in range(1,K):
    if (K//i)%2!=0:
      q+=(1/N)*((1/2)**(i*int(math.log(K/i,2))+1))
    else:
      q+=(1/N)*((1/2)**(int(math.log(K/i,2))))
print(q)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
import math
 #qは０点になる場合の数
if N>=K:
  q=(N-K+1)*(1/N)
  for i in range(1,K):
    if (K//i)%2!=0:
      q+=(1/N)*((1/2)**(i*int(math.log(K/i,2))+1))
    else:
      q+=(1/N)*((1/2)**(int(math.log(K/i,2))))
else:
  q=0
  for i in range(1,K):
    if (K//i)%2!=0:
      q+=(1/N)*((1/2)**(i*int(math.log(K/i,2))+1))
    else:
      q+=(1/N)*((1/2)**(int(math.log(K/i,2))))
print(N/(N+q))

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
import math
 #qは０点になる場合の数
if N>=K:
  q=(N-K+1)*(1/N)
  for i in range(1,K):
    if (K//i)%2!=0:
      q+=(1/N)*(1/2)**(i*int(math.log(K/i,2))+1)
    else:
      q+=(1/N)*(1/2)**(int(math.log(K/i,2)))
else:
  q=0
  for i in range(1,K):
    if (K//i)%2!=0:
      q+=(1/N)*(1/2)**(i*int(math.log(K/i,2))+1)
    else:
      q+=(1/N)*(1/2)**(int(math.log(K/i,2)))
print(N/(N+q))

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
import math
q=0 #qは０点になる場合の数
if N>=K:
  for i in range(1,K):
    if (K//i)%2!=0:
      q+=int(math.log(K/i,2))+1
    else:
      q+=int(math.log(K/i,2))
else:
  for i in range(1,N+1):
    if (K//i)%2!=0:
      q+=int(math.log(K/i,2))+1
    else:
      q+=int(math.log(K/i,2))
print(N/(N+q))

Submission status: Wrong Answer

Solution code:
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    N, K = map(int, input().split())

    import math

    res = float(0)

    for score in range(1, N+1):
        p = 1.0/N
        if K > score:
            n = math.floor(math.log2(K/score)+1)
            p = p/(2**n)
        res = res + p

    print(res)

# %%
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):
    if i < k:
        ans += 1/2**math.ceil(math.log(k/i,2))
        print(2**math.ceil(math.log(k/i,2)))
    else:
        ans += 1
print(ans/n)

Submission status: Wrong Answer

Solution code:
import numpy as np

n, k = map(int, input().split())
e = 0
for i in range(1, n + 1):
    if i < k:
        sh = int(np.log2(k) - np.log2(i) + 1)  # 何回コインを投げるか
        e += (1 / n) * 0.5 ** sh
    else:
        e += (1 / n)
print(e)

Submission status: Wrong Answer

Solution code:
import numpy as np

n, k = map(int, input().split())
e = 0
for i in range(1, n + 1):
    if i < k:
        sh = int(np.log2(k) - np.log2(i) + 1)  # 何回コインを投げるか
        e += (1 / n) * (1 / 2) ** sh
    else:
        e += (1 / n)
print(e)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
ans = 0

for i in range(1, a+1):
  for j in range(10**5):
    if i*2**j > b:
      ans += a*2**j
      break

print(1/ans)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
ans = 0

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

print('{:.15f}'.format(ans))

Submission status: Wrong Answer

Solution code:
from fractions import Fraction
a, b = map(int, input().split())
ans = 0

for i in range(1, a+1):
  for j in range(10**6):
    if i*2**j > b:
      ans += Fraction(1, a*2**j)
      break

print(float(ans))

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
ans = 0

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

tol = 10 ** -9

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


def calc_exponent(k, i):
    tmp = math.log2(k / i)
    tmp2 = tmp // 2
    return int(tmp) if 10 ** -9 > abs(tmp - tmp2) else int(tmp) + 1


if n < k:
    ans = 0
    for i in range(1, n+1):
        ans += 0.5 ** calc_exponent(k, i)
    print(ans / n)
else:
    ans = 0
    for i in range(1, k-1):
        ans += 0.5 ** calc_exponent(k, i)
    print((n - k + 1) / n + ans * (k-1) / n)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

import math

res = float(0)

for score in range(1, N+1):
    p = 1.0/N
    if K > score:
        n = math.floor(math.log2(K/score)+1)
        p = p/(2**n)
    res = res + p

print(res)

Submission status: Wrong Answer

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

import math

res = float(0)

for score in range(1, N+1):
    p = 1/N
    if K > score:
        n = int(math.floor(math.log2(K/score)+1))
        p = p/(2**n)
    res = res + p

print(res)

Submission status: Wrong Answer

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

import math

res = float(0)

for score in range(1, N+1):
    p = float(1/N)
    if K > score:
        n = math.floor(math.log2(K/score)+1)
        p = p/(2**n)
    res = res + p

print(res)

Submission status: Wrong Answer

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

import math

p = 0
for score in range(1, N+1):
    if score > K:
        num = 0
        p = p + 1/N
    else:
        num = math.floor(math.log2(K/score)+1)
        p = p + 1/N*(1/2)**num

print(p)

Submission status: Wrong Answer

Solution code:
import math

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

l = []
if N <= K:
    for i in range(N):
        a = int(math.log2(K/(i+1))) + 1
        l.append((1/N) * ((1/2) ** a))
else:
    for i in range(1, K):
        a = int(math.log2(K/i)) + 1
        l.append((1/N) * ((1/2) ** a))
    l.append((N-K+1)/N)

print(sum(l))

Submission status: Wrong Answer

Solution code:
import math

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

l = []
if N < K:
    for i in range(N):
        a = int(math.log2(K/(i+1))) + 1
        l.append((1/N) * ((1/2) ** a))
else:
    for i in range(1, K):
        a = int(math.log2(K/i)) + 1
        l.append((1/N) * ((1/2) ** a))
    l.append((N-K+1)/N)

print(sum(l))

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(n):
    if i < k:
        count = math.ceil(math.log2(k/(i+1)))
        print(count)
        p += 1/(2**count)
    else:
        p += 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):
    if i < k:
        count = math.ceil(math.log2(k/(i+1)))
        print(count)
        p += 1/n/(2**count)
    else:
        p += 1/n

print(p)

Submission status: Wrong Answer

Solution code:
def half(n):
    return n / 2

n,k=map(int,input().split())
cnt = [1/n]*n
ans = 0
if n >= k:
    ans += sum(cnt[k-1:])
    cnt = [1/n]*(k-1)
if n != k:
    cnt = list(map(half,cnt))
while k > 1:
    a = k
    k /= 2
    a //= 2
    if n <= a:
        cnt = list(map(half,cnt))
    else:
        ans += sum(cnt[int(a):])
        cnt = list(map(half,cnt[:int(a)]))
ans += sum(cnt)
print(ans)

Submission status: Wrong Answer

Solution code:
def half(n):
    return n / 2

n,k=map(int,input().split())
cnt = [1/n]*n
ans = 0
if n >= k:
    ans += sum(cnt[k-1:])
    cnt = [1/n]*(k-1)
cnt = list(map(half,cnt))
while k > 1:
    a = k
    k /= 2
    a = a//2
    if n <= a:
        cnt = list(map(half,cnt))
    else:
        ans += sum(cnt[int(a):])
        cnt = list(map(half,cnt[:int(a)]))
ans += sum(cnt)
print(ans)

Submission status: Wrong Answer

Solution code:
def half(n):
    return n / 2

n,k=map(int,input().split())
cnt = [1/n]*n
ans = 0
if n >= k:
    ans += sum(cnt[k-1:])
    cnt = [1/n]*(k-1)
while k > 1:
    a = k
    k /= 2
    a = -(-a//2)
    if n <= a:
        cnt = list(map(half,cnt))
    else:
        ans += sum(cnt[int(a):])
        cnt = list(map(half,cnt[:int(a)]))
ans += sum(cnt)
print(ans)

Submission status: Wrong Answer

Solution code:
from math import log2, ceil

n, k = map(int, input().split())
p = ceil(log2(k/n))
s = 0
for i in range(n, 0, -1):
    if i*2**p < k:
        p += 1
    s += 0.5**p

print(s/n)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a, b, i = n, k, 0
sum = 0

while n < k*0.5**i:
    i += 1

sum += (n-int((k-1)*0.5**i))*0.5**i

while k*0.5**(i) >= 1:
    i += 1
    sum += (int(k*0.5**(i-1))-int(k*0.5**(i)))*0.5**(i)

print(sum/n)

Submission status: Wrong Answer

Solution code:
n , k = (int(x) for x in input().split())

if n > k:
  prob = (n-k+1)/n
  start = k-1
else:
  prob = 0
  start = n

power = 0 
while start*(2**power) < k:
	power += 1

limit = k//2
for i in range(start,0,-1):
  while i*(2**power) < k:
    power += 1
  prob += (1/n)*(1/2)**power
  if i == limit:
    power += 1
print(prob)

Submission status: Wrong Answer

Solution code:
n , k = (int(x) for x in input().split())

if n > k:
  prob = 1-k/n
  start = k
else:
  prob = 0
  start = n

power = 0 
while start*(2**power) < k:
	power += 1

limit = k//2
for i in range(start,0,-1):
  while i*(2**power) < k:
    power += 1
  prob += (1/n)*(1/2)**power
  if i == limit:
    power += 1
print(prob)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(1, n + 1):
    if i >= k:
        p += 1
    else:
        count = int(math.log(k / i, 2) + 1)
        p += 0.5 ** count
p /= n
print(p)