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 numpy as np

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

ans = 0
for i in range(1, min(N+1, K)):
    #print(2 ** -np.ceil(np.log2(K/i)))
    ans += 2 ** -np.ceil(np.log2(K/i))

ans = ans/N

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

print(ans)

Submission status: Wrong Answer

Solution code:
def get_c(p, k):
    c = 1
    while 1:
        if p * pow(2, c) >= k:
            return c
        c += 1


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

# check
prob = [1 / N] * N
for p, i in zip(range(1, N + 1), range(N)):
    c = get_c(p, K)
    prob[i] *= (1 / 2) ** c

print(sum(prob))

Submission status: Wrong Answer

Solution code:
def get_c(p):
    c = 1
    while 1:
        if pow(2, c) >= p:
            return c
        c += 1


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

# check
prob = [1 / N] * N
for p, n in zip(range(1, N + 1), prob):
    c = get_c(K - p)
    n *= 0.5 ** c

print(sum(prob))

Submission status: Wrong Answer

Solution code:
def get_c(p):
    c = 1
    while 1:
        if pow(2, c) >= p:
            return c
        c += 1


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

# check
prob = [1 / N] * N
for p, n in zip(range(1, N + 1), prob):
    c = get_c(N - p)
    n *= 0.5 ** c

print(sum(prob))

Submission status: Wrong Answer

Solution code:
from math import log2
n,k = map(int,input().split())
if k == 1:
    print(1)
    exit()
l = []
cnt = 0
for i in range(1,n+1):
    if i < k:
        l.append(int(log2(k/i))+1)
    else:
        cnt += 1
maxi = max(l)
preans = cnt * 2**maxi
for i in l:
    preans += 2**(maxi-i)
ans = preans / (n*2**maxi)
print('{:.15f}'.format(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:
        ans += 1/2**(int(log2(k/i))+1)
    else:
        ans += 1
ans /= n
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

s = 0

for i in range(1, N + 1):
    s += 1 / math.pow(2, max(0, math.ceil(math.log2(K)) - math.ceil(math.log2(i))))

print(s / N)

Submission status: Wrong Answer

Solution code:
import math

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

s = 0

for i in range(1, N + 1):
    if K > i:
        s += 1 / math.pow(2, math.ceil(math.log2(K)) - math.ceil(math.log2(i)))
    else:
        s += 1

print(s / N)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

import math
import numpy as np
def lambda_p(k,n):
  #print(k,n)
  m=math.ceil(math.log(k,2))
  #print(k,n,m)
  p=1/n # for 2**0
  #p*=1/2
  for ii in range(m):
    p*=1/2      
    #print(ii,2**(ii+1)+1,n+1,2**(ii+1)+1)
    for jj in np.arange(2**ii+1,min(n,2**(ii+1))+1):
      #print(ii,jj)
      p+=1/n
    #print(ii)
  return p

def lambda_nk(n,k):
  #return (k+n)*(n-k+1)/(n*n)
  return k/n

#print(lambda_nk(n,k),(1-lambda_nk(n,k)),lambda_p(k,k))

if n>k:
  r=lambda_nk(n,k)*lambda_p(k,k)+(1-lambda_nk(n,k))
else:
  r=lambda_p(k,n)
print(r)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()

P = 1/N
ans = max(0, (N-K+1)/N)
print(ans)

for i in range(1, min(N+1, K)):
	ans += P*0.5**(ceil(log2(K/i)))

print("{:12}".format(ans))

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()

P = 1/N
ans = max(0, (N-K+1)/N)
print(ans)

for i in range(1, min(N+1, K)):
	ans += P*0.5**(ceil(log2(K/i)))

print(ans)

Submission status: Wrong Answer

Solution code:
import math

n,k = map(int,input().split(" "))
ret = 0
for i in range(1,n+1):
    fraq = math.ceil(math.log2(k/i))
    ret += (1/n) * (1/2)**fraq

print(ret)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


print(sum([(1/N)*(0.5)**math.ceil(math.log2(max(K//i,1))) for i in range(1,N+1)]))

Submission status: Wrong Answer

Solution code:
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    N,K=pin()
    MAGICNUMBER=17 #2**MAGICNUMBER>10**5>=M
    ans_x3=0
    for i in range(1,N+1):
        temp=i
        coins=0
        for j in range(MAGICNUMBER):
            if temp>=K:
                coins=j
                break
            temp*=2
        #print()
        ans_x3+=(2**(0-coins))*(10**20)
    t=int(ans_x3//N)
    print(t/(10**20))   
#%%submit!
resolve()

Submission status: Wrong Answer

Solution code:
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    N,K=pin()
    MAGICNUMBER=17 #2**MAGICNUMBER>10**5>=M
    ans_x3=0
    for i in range(1,N+1):
        temp=i
        coins=0
        for j in range(MAGICNUMBER):
            if temp>=K:
                coins=j
                break
            temp*=2
        #print()
        ans_x3+=(2**(0-coins))*(10**10)
    t=int(ans_x3//N)
    print("0.{}".format(t))    
#%%submit!
resolve()

Submission status: Wrong Answer

Solution code:
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    N,K=pin()
    MAGICNUMBER=17 #2**MAGICNUMBER>10**5>=M
    ans_x3=0
    for i in range(1,N+1):
        temp=i
        coins=0
        for j in range(MAGICNUMBER):
            if temp>=K:
                coins=j
                break
            temp*=2
        #print()
        ans_x3+=(2**(17-coins))
    print((ans_x3/N)*(2**(-17)))
        
#%%submit!
resolve()

Submission status: Wrong Answer

Solution code:
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    N,K=pin()
    MAGICNUMBER=17
    ans_x3=0
    for i in range(1,N+1):
        temp=i
        coins=0
        for j in range(MAGICNUMBER):
            if temp>=K:
                coins=j+1
                break
            temp*=2
        #print()
        ans_x3+=2**(coins*(-1))
    print(ans_x3*2/N)
        
#%%submit!
resolve()

Submission status: Wrong Answer

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

total = 0
for i in range(1, n+1):
  tmp = 1 / n
  
  now = i
  while now <= k:
    now *= 2
    tmp /= 2
  total += tmp
    

print(total)

Submission status: Wrong Answer

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

total = []
for i in range(1, n+1):
  if i < k:
    total.append( 2 ** (-len(format(k//i, "b"))) / n)
  else:
    total.append(2**0 / n)
    

print(sum(total))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

two_beki = [1]*20
for i in range(1,20):
    two_beki[i] = 2**i
#[1,2,4,8,16,32,64,128,256,512,1024,2048,8192,16384]
n = N+1
list_index = list()
for I in range(1,n):
    for J in range(20):
        if(I*two_beki[J]>=K):
            list_index.append(J) 
            # print(J,I*two_beki[J])
            break
print(list_index)
sum_harf = 0.0
for I in list_index:
    sum_harf += 1/two_beki[I]/N
print(sum_harf)

Submission status: Wrong Answer

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

two_beki = [1]*15
for i in range(1,15):
    two_beki[i] = 2**i
#[1,2,4,8,16,32,64,128,256,512,1024,2048,8192,16384]
n = N+1
list_index = list()
for I in range(1,n):
    for J in range(15):
        if(I*two_beki[J]>=K):
            list_index.append(J) 
            # print(J,I*two_beki[J])
            break
# print(list_index)
sum_harf = 0.0
for I in list_index:
    sum_harf += 1/two_beki[I]
print(sum_harf/N)

Submission status: Wrong Answer

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

if n > k:
    kati = (n -(k-1))/n
else:
    kati = 0

for i in range(1, min(n+1, k)):
    total = i
    kakuritsu = 1/n
    while total < k:
        kakuritsu *= 0.5
        total *= 2
    kati += kakuritsu

print(kati)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
C=[]
c=1
while c<K:
  c*=2
  C.append(c)
C.reverse()

ans=0
h=min(N,len(C))
for i in range(h):
  ans+=1/(C[i])

d=N-len(C)
if d>0:
  ans+=d
print(ans/N)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
C=[]
c=1

while c<K:
  c*=2
  C.append(c)
C.reverse()
ans=0
h=min(N,len(C))
for i in range(h):
  ans+=1/(C[i]*N)
d=N-len(C)
if d>0:
  ans+=d/N
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

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

    
resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def dice_and_coin(n, k):

    ans = 0

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

    return ans

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import log

n, k = map(int, input().split())
ans = 0
for i in range(n):
    x = int(log(k / (i + 1), 2)) + 1
    ans += (1 / n) * 0.5**x
print('{:.12f}'.format(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

p1 = max(N - K + 1, 0) / N
p2 = 0.
l2K = np.log2(K)
for k in range(1, min(K, N+1)):
    p2 += (1 / N) * (0.5) ** int(l2K - np.log2(k) + 1)

print(p1 + p2)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import math

def main():
    N, K = map(int, input().split(' '))
    
    result = 1 / N * sum([math.pow(0.5, math.ceil(math.log2(K / n))) if n < K else 1.0 for n in range(1, N + 1)])
    print('{:f}'.format(result))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import random
N,K = map(int,input().split())
numGames = 1000
win = 0


for i in range(1,numGames):
    score = random.randrange(1,N+1,1)

    while (score>0 and score<K):
        coinResult = random.randrange(1,3,1)#1=head,2=tail
        if (coinResult==1):
            score = score*2
        else:
            score = 0
    
    if(score>=K):
        win = win+1

print(win/numGames)

Submission status: Wrong Answer

Solution code:
n,k = map (int,input().split())
ans = n + 0.0
s = 1
t = k
while t >= 1:
    a = min (t,n)
    ans -= a / 2**s
    t = k // 2**s
    s += 1
print(ans/n)

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:
        n = int(math.log(K/i, 2) + 1)
        ans += (1/N) * (1/2)**n
    else:
        ans += (1/N)
print(format(ans, '.12f'))

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:
        n = int(math.log(K/i, 2) + 1)
        ans += (1/N) * (1/2)**n
    else:
        ans += (1/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):
    if i < K:
        n = int(math.log(K/i, 2))+1
        ans += (1/N) * (1/2)**n
    else:
        ans += (1/N)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n,k=map(int,input().split())
n_lis=[int(i) for i in range(1,n+1)]
p=float(1/n)
p_lis=[]
for i in range(n):
    if n_lis[i]<k:
        atai=float(k/n_lis[i])
        kaisu=int(math.log(atai,2))+1
        p_lis.append((1/2)**(kaisu))
    else:
        p_lis.append(1)

print(p*sum(p_lis))

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.log2(K)-math.log2(i)
    x = int(x) if x.is_integer() else int(x) + 1
    ans += (1/N) * pow(1/2,x)
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):
    if i < K:
        ANS += (1/N) * (0.5**(math.ceil(math.log((K/i),2))))
    else:
        ANS += (1/N)*(N-K+1)
        break
    print(math.ceil(math.log((K/i),2)))

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):
    if i < K:
        ANS += (1/N) * (0.5**(math.ceil(math.log(math.floor(K/i),2))))
    else:
        ANS += (1/N)*(N-K+1)
        break
    print(math.ceil(math.log(math.floor(K/i),2)))

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):
    if i < K:
        ANS += (1/N) * (0.5**(math.ceil(math.log(math.ceil(K/i),2))))
    else:
        ANS += (1/N)*(N-K+1)
        break
    print(math.ceil(math.log(math.ceil(K/i),2)))

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):
    if i < K:
        ANS += (1/N) * (0.5**(math.ceil(math.log(int(K/i),2))))
    else:
        ANS += (1/N)*(N-K+1)
        break
    print(math.ceil(math.log(int(K/i),2)))

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):
    if i < K:
        ANS += (1/N) * (0.5**(math.ceil(math.log((K/i),2))))
    else:
        ANS += (1/N)*(N-K+1)
        break
    print(math.ceil(math.log((K/i),2)+1))

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):
    if i < K:
        ANS += (1/N) * (0.5**(int(math.log((K/i),2)+1)))
    else:
        ANS += (1/N)*(N-K+1)
        break
    print(int(math.log((K/i),2)+1)+1)

print(ANS)

Submission status: Wrong Answer

Solution code:
import math
from sys import stdin

n, k = map(int, stdin.readline().rstrip().split())
ans = 0
for i in range(1, n + 1):
    if k / i <= 1:
        ans += (1 / n)
    else:
        ans += (1 / n) / 2 ** (int(math.log2(k / i)) + 1)
print(ans)

Submission status: Wrong Answer

Solution code:
# import fractions
# import sys
import math
from sys import stdin

n, k = map(int, stdin.readline().rstrip().split())
ans = 0
for i in range(1, n + 1):
    if k / i <= 1:
        ans += (1 / n)
    else:
        # tmp = 0
        # for j in range(k // i + 1):
        #     if 2 ** j > k // i:
        #         tmp = j
        #         break
        # print(int(math.log2(k / i)) + 1, tmp)
        ans += (1 / n) * (1 / 2) ** (int(math.log2(k // i)) + 1)
print(ans)

Submission status: Wrong Answer

Solution code:
# import fractions
# import sys
import math
from sys import stdin

n, k = map(int, stdin.readline().rstrip().split())
ans = 0
for i in range(1, n + 1):
    if k / i < 1:
        ans += (1 / n)
    else:
        # tmp = 0
        # for j in range(k // i + 1):
        #     print(2 ** j, k // i, j)
        #     if 2 ** j > k // i:
        #         tmp = j
        #         break
        # print(int(math.log2(k / i)) + 1, tmp)
        ans += (1 / n) * (1 / 2) ** (int(math.log2(k / i)) + 1)
print(ans)

Submission status: Wrong Answer

Solution code:
# import fractions
# import sys
import math
from sys import stdin

n, k = map(int, stdin.readline().rstrip().split())
ans = 0
for i in range(1, n + 1):
    if k / i <= 1:
        ans += (1 / n)
    else:
        tmp = 0
        for j in range(k // i + 1):
            # print(2 ** j, k // i, j)
            if 2 ** j > k // i:
                tmp = j
                break
        # print(int(math.log2(k / i)) + 1, tmp)
        ans += (1 / n) * (1 / 2) ** tmp
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

r = 0
max_cnt = int(log2(K)) + 1

for i in range(1,N+1):
    count = int(log2(K / i)) + 1 if i < K else 0

    r += 2 ** (max_cnt - count)
r = r / (N * (2 ** max_cnt))

print(r)

Submission status: Wrong Answer

Solution code:
from math import log2

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

r = 0
max_cnt = int(log2(K)) + 1
print(max_cnt)
for i in range(1,N+1):
    count = int(log2(K / i)) + 1 if i < K else 0
    r += 2 ** (max_cnt - count)
r = r / (N * (2 ** max_cnt))

print(r)

Submission status: Wrong Answer

Solution code:
from math import log2

N,K = map(int,input().split())
r = 0
max_cnt = int(log2(K)) + 1
for i in range(1,N+1):
    count = int(log2(K / i)) + 1 if i >= K else 0
    r += 2 ** (max_cnt - count)
r = r / (N * 2 ** max_cnt)

print(r)

Submission status: Wrong Answer

Solution code:
from math import log2

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

r = 0
max_cnt = int(log2(K)) + 1
for i in range(1,N+1):
    if i >= K:
        r += 2 ** max_cnt
        continue
    count = int(log2(K / i)) + 1
    r += 2 ** (max_cnt - count)
r = r / N / 2 ** max_cnt

print(r)

Submission status: Wrong Answer

Solution code:
from math import log2

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

r = 0
for i in range(1,N+1):
    if i >= K:
        r += 1.0
        continue
    count = int(log2(K / i)) + 1
    r += (1.0 / (2 ** count))
r = r / N

print(r)

Submission status: Wrong Answer

Solution code:
from math import log2

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

r = 0
for i in range(1,N+1):
    if i >= K:
        r += 1.0 / N
        continue
    count = int(log2(K / i)) + 1

    r += (1.0 / N) * (1.0 / (2 ** count))

print(r)

Submission status: Wrong Answer

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

r = 0
for i in range(1,N+1):
    if i >= K:
        r += 1.0 / N
        continue
    count = int(log2(K / i)) + 1

    r += 1.0 / (N * (2 ** count))

print(r)

Submission status: Wrong Answer

Solution code:
n,K = map(int,input().split())
p = min(n,K-1)
ans = 0
chk = [1]*(K-1)
k = K
for i in range(15):
  k /= 2
  if k == int(k):
    q = int(k*2-k-1)
  else:
    q = int(k*2-k)
  for i in range(q):
    chk[i] += 1
  if k <= 1:
    break
    
#print(chk)
for i in range(p):
  ans += float(1/(2**chk[i]*n))
  #print(ans)
ans += max(0,(n-K+1)/n)
print(ans)

Submission status: Wrong Answer

Solution code:
n,K = map(int,input().split())
p = min(n,K-1)
ans = 0
chk = [1]*(K-1)
k = K
for i in range(14):
  k /= 2
  if k == int(k):
    q = int(k*2-k-1)
  else:
    q = int(k*2-k)
  for i in range(q):
    chk[i] += 1
  if k <= 1:
    break
    
#print(chk)
for i in range(p):
  ans += float(1/(2**chk[i]*n))
  #print(ans)
ans += max(0,(n-K+1)/n)
print(ans)

Submission status: Wrong Answer

Solution code:
n,K = map(int,input().split())
p = min(n,K-1)
ans = 0
chk = [1]*(K-1)
k = K
for i in range(14):
  k /= 2
  for i in range(int(k*2-k-0.0000000000000000001)):
    chk[i] += 1
  if k <= 1:
    break
    
#print(chk)
for i in range(p):
  ans += float(1/(2**chk[i]*n))
  #print(ans)
ans += max(0,(n-K+1)/n)
print(ans)

Submission status: Wrong Answer

Solution code:
n,K = map(int,input().split())
p = min(n,K-1)
ans = 0
chk = [1]*(K-1)
k = K
for i in range(14):
  k /= 2
  for i in range(int(k*2-k-0.000000001)):
    chk[i] += 1
  if k <= 1:
    break
    
#print(chk)
for i in range(p):
  ans += float(1/(2**chk[i]*n))
  #print(ans)
ans += max(0,(n-K+1)/n)
print(ans)

Submission status: Wrong Answer

Solution code:
n,K = map(int,input().split())
p = min(n,K-1)
ans = 0
chk = [1]*(K-1)
k = K
for i in range(14):
  k /= 2
  for i in range(int(k*2-k)):
    chk[i] += 1
  if k <= 1:
    break
    
#print(chk)
for i in range(p):
  ans += float(1/(2**chk[i]*n))
  #print(ans)
ans += max(0,(n-K+1)/n)
print(ans)

Submission status: Wrong Answer

Solution code:
n,K = map(int,input().split())
p = min(n,K-1)
ans = 0
chk = [1]*(K-1)
k = K
for i in range(14):
  k /= 2
  for i in range(int(k*2-k)):
    chk[i] += 1
  if k <= 1:
    break
#chk = sorted(chk,reverse=True)
#print(chk)
for i in range(p):
  #print(i)
  ans += float(1/(2**chk[i]))
  #print(ans)
ans += max(0,n-K+1)
print(ans/n)

Submission status: Wrong Answer

Solution code:
n,K = map(int,input().split())
p = min(n,K-1)
ans = 0
chk = [1]*(K-1)
k = K
for i in range(14):
  k /= 2
  for i in range(int(k*2-k)):
    chk[i] += 1
  if k <= 1:
    break
#chk = sorted(chk,reverse=True)
print(chk)
for i in range(p):
  print(i)
  ans += float(1/(2**chk[i]))
  #print(ans)
ans += max(0,n-K+1)
print(ans/n)

Submission status: Wrong Answer

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from itertools import combinations # (string,3) 3回
#from collections import deque
#import collections.defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n,k = readInts()
    # サイコロの出た目が1から考えてみる?
    i = 1
    cnt = 0
    while i < k:
        cnt += 1
        i *= 2
    #print(i,cnt)
    ans = 0
    for i in range(cnt,1,-1):# 分子が等比数列
        #print(cnt)
        ans += (1/n) * ((1/2) ** i)
    for i in range(cnt+1,n+1):
        ans += (1/n)
    print(ans)
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
point = 0
if k <= n:
    point += (n-k+1)/n

for i in range(1,min(k+1,n+1)):
    now = i
    ima = 0
    while now < k:
        now *= 2
        ima += 1
    point += (1/n)*(1/2)**(ima)

print(point)

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

Submission status: Wrong Answer

Solution code:
n, k = list(map(int, input().split()))
total = [2 ** (-len(format(k//i, "b"))) for i in range(1, n+1)]
print(sum(total) / n)

Submission status: Wrong Answer

Solution code:
from math import log,ceil,floor
N,K = map(int,input().split())
b = ceil(log(K,2))
t = floor(log(K,2))
ans = 0
def T(a,x):
    i = 0
    while a < x:
        a *= 2
        i += 1
    return i
for i in range(1,b):
    t = T(i,K)
    ans += (1/N) * ((1/2)**t)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def calc_num(n):
    num = 0
    while(n <= K):
        num += 1
        n *= 2
    return num


for i in range(1,N+ 1):
    if i >= K:
        P.append(-1)
        continue
    P.append(calc_num(i))

for p in P:
    if p < 0:
        ans += 1/N
    else:
        ans += (1/N) * ((1/2) ** p)

print(ans)

Submission status: Wrong Answer

Solution code:
N, K = [int(i) for i in input().split(" ")]
P = [0 for _ in range(N+1)]
P_en = [False for _ in range(N+1)]
ans = 0

def calc_num(n):
    num = 0
    while(n <= K):
        num += 1
        n *= 2
    return num

for i in range(N):
    i += 1
    if i >= K:
        P[i] = 1
        continue

    if P_en[i]:
        continue
    else:
        num = calc_num(i)
        P[i] = num
        i *= 2
        while(i <= N):
            if num > 0:
                P[i] = num - 1
                num -= 1
                i += 2
            else:
                break

for n,p in enumerate(P[1:]):
    n += 1
    if n >= K:
        ans += 1/N
    else:
        ans += (1/N) * ((1/2) ** p)
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,n+1):
    if i >= k:
        ans += 1/n
    else:
        num = int((np.log2(k/i)+1)//1)
        ans += (1/n)*(1/2)**num
    
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,n+1):
    if i >= k:
        ans += 1/n
    else:
        if k//i == 0 :
            num = 1
        else:
            num = int((np.log2(k/i)+1)//1)
        ans += (1/n)*(1/2)**num
    
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,n+1):
    if i >= k:
        ans += 1/n
    else:
        if k//i == 0 :
            num = 1
        else:
            num = int((np.log2(k//i)+1)//1)
        ans += (1/n)*(1/2)**num
    
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n, k = map(int, input().split())
pro = 0
for i in range(1,n+1):
  x = i
  a = 0
  while x < k:
    a += 1
    x = x*2**a
  pro += (1/n) * 0.5**a
print(pro)

Submission status: Wrong Answer

Solution code:
import math
n, k = map(int, input().split())
pro = 0
for i in range(1,n+1):
  x = i
  a = 0
  while x < k:
    a += 1
    x = x*2**a
  pro += (i/n) * 0.5**a
print(pro)