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())
NUM=[0]*N
bunsu=[0]*N

for i in range(N):
    NUM[i]=math.ceil(K/(i+1))
    total=i+1
    for j in range(1,2**10):
        total=total*2
        if(total>K):
            break

    bunsu[i]=1/(N*(2**j))

print(sum(bunsu))

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
import math
 
def main():
 
    N,K = map(int, input().split())
    ans = 0
    for i in range(1,N+1):
        if i+1 >= K:
            ans += 1.0/N
        else:
            ans += 1.0/N * 0.5**math.ceil(math.log2(K/(i+1)))
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
import math
 
def main():
 
    N,K = map(int, input().split())
    ans = 0
    for i in range(1,N+1):
        if i+1 >= K:
            ans += 1.0/N
        else:
            ans += 1.0/N * 0.5**math.ceil(math.log2(K/(i)))
    print(ans)

Submission status: Wrong Answer

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

for i in range(1,N+1):
    answer += 1/(N * 2**(math.ceil(math.log((K/i),2))))
print(answer)

Submission status: Wrong Answer

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

import math

def main(): 

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
list = range(1,N+1)
ans=[0]*N
i = 1
j = 0

for n in reversed(list):
    while n*i < K:
        print(n,i)
        i = i*2
    ans[n-1] = i
print(ans)
for k in ans:
    j += 1/k

print((1/N)*j)

Submission status: Wrong Answer

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

def main(N,K):
    ans = 1
    for i in range(1,N+1):
        tmp = 1/N
        score = i
        count = 0
        while(K>score):
            score *= 2
            count += 1
        tmp /= (2**count)
        ans += tmp
    print(ans)

if __name__ == '__main__':
    N, K = map(int, input().split())
    main(N,K)

Submission status: Wrong Answer

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

ans=[0 for i in range(m+1)]

def calc(n,k,cnt):
    k=int(-(-k//2))
    cnt/=2
    if k==1:
        ans[1]=cnt/m
        return
    elif n < k:
        calc(n,k,cnt)
    else:
        for i in range(k,n+1):
            ans[i]=cnt/m
        n=int(-(-n//2))
        calc(n,k,cnt)

if m > k:
    calc(k-1,k,1)
    for i in range(k,m+1):
        ans[i]=1/m
else:
    calc(m,k,1)

print(sum(ans))

Submission status: Wrong Answer

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

ans=[0 for i in range(m+1)]

def calc(n,k,cnt):
    k=int(-(-k//2))
    cnt/=2
    if k==1:
        ans[1]=cnt/m
        return
    elif n < k:
        calc(n,k,cnt)
    else:
        for i in range(k,n+1):
            ans[i]=cnt/m
        n=int(-(-n//2))
        calc(n,k,cnt)

if m >= k:
    calc(k-1,k,1)
    for i in range(k,m+1):
        ans[i]=1/m
else:
    calc(m,k,1)

print(sum(ans))

Submission status: Wrong Answer

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

ans=[0 for i in range(n+1)]

def calc(n,k,cnt):
    k=int(-(-k//2))
    cnt/=2
    if k==1:
        ans[1]=cnt
        return
    elif n < k:
        calc(n,k,cnt)
    else:
        for i in range(k,n+1):
            ans[i]=cnt
        n=int(-(-n//2))
        calc(n,k,cnt)

if n >= k:
    calc(k-1,k,1)
    for i in range(k,n+1):
        ans[i]=1
else:
    calc(n,k,1)

print(sum(ans)/n)

Submission status: Wrong Answer

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

ans=[0 for i in range(n+1)]

def calc(n,k,cnt):
    k=int(-(-k//2))
    cnt/=2
    if k==1:
        ans[1]=cnt
        return
    elif n < k:
        calc(n,k,cnt)
    else:
        for i in range(k,n+1):
            ans[i]=cnt
        n=int(-(-n//2))
        calc(n,k,cnt)

if n >= k:
    calc(n,k,1)
    for i in range(k,n+1):
        ans[i]=1
else:
    calc(n,k,1)

print(sum(ans)/n)

Submission status: Wrong Answer

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

ans=[0 for i in range(n+1)]

def calc(n,k,cnt):
    k=int(-(-k//2))
    cnt/=2
    if k==1:
        ans[1]=cnt
        return
    elif n < k:
        calc(n,k,cnt)
    else:
        for i in range(k,n+1):
            ans[i]=cnt
        n=int(-(-n//2))
        calc(n,k,cnt)

if n >= k:
    calc(n,k,1)
    for i in range(k,n+1):
        ans[i]=1
else:
    calc(n,k,1)

print(ans)
print(sum(ans)/n)

Submission status: Wrong Answer

Solution code:

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

ans = 0.0
for i in range(1, n+1):
    j = k
    count = 0
    while i <= int(j):
        j /= 2
        count += 1

#    print(count)
    ans += (1/n * (0.5 ** count))

print(ans)

Submission status: Wrong Answer

Solution code:

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

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

#    print(count)
    ans += (1/n * (0.5 ** count))

print(ans)

Submission status: Wrong Answer

Solution code:

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

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

    ans += (1/n * (0.5 ** count))

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import math
N, K = map(int, input().split())
ans = 0

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

	for i in range(1, K):
		j = math.floor((math.log2((K - 1) / i)) + 1)
		print(j)
		ans += (1 / N) * (1 / 2) ** j

else:
	for i in range(1, N + 1):
		j = math.floor((math.log2((K - 1) / i)) + 1)
		ans += (1 / N) * (1 / 2) ** j

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import math
N, K = map(int, input().split())
ans = 0

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

	for i in range(1, K):
		j = math.ceil(math.log2((K - 1) / i))
		ans += (1 / N) * (1 / 2) ** j

else:
	for i in range(1, N + 1):
		j = math.ceil(math.log2((K - 1) / i))
		ans += (1 / N) * (1 / 2) ** j

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import math
N, K = map(int, input().split())
ans = 0

if N > K - 1:
	ans = 1
	print(ans)
	exit()

for i in range(1, N + 1):
	j = math.ceil(math.log2((K - 1) / i))
	ans += (1 / N) * (1 / 2) ** j

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
        count +=1
    ans += 1/n * (0.5** count)

print(ans)

Submission status: Wrong Answer

Solution code:
import math
n, k = map(int, raw_input().split())
p = 0.0
for i in range(1,n+1):
    if i < k:
        x = math.ceil(math.log((float(k) / float(i)), 2))
        print "---"
        print x
        print i * (2 ** x)
        p += (float(1) / float(n)) * ((0.5) ** x)
    else:
        p += (float(1) / float(n))
print p

Submission status: Wrong Answer

Solution code:
import math
N, K = map(int, input().split())
#N = 3
#K = 10
s = 0
for i in range(1,min(N, K)+1):
    s += (1/N)*(1/2)**(math.ceil((math.log(K) - math.log(i))/ math.log(2)))
s += (1/N) * (max(N, K) - K)
print(round(s,9))

Submission status: Wrong Answer

Solution code:
import math
N, K = map(int, input().split())
#N = 3
#K = 10
s = 0
for i in range(1,min(N, K)+1):
    s += (1/N)*(1/2)**(math.ceil((math.log(K) - math.log(i))/ math.log(2)))
s += (1/N) * (max(N, K) - K)
print(round(s,10))

Submission status: Wrong Answer

Solution code:
import math
N, K = map(int, input().split())
#N = 3
#K = 10
s = 0
for i in range(1,min(N, K)+1):
    s += (1/N)*(1/2)**(math.ceil((math.log(K) - math.log(i))/ math.log(2)))
s += (1/N) * (max(N, K) - K)
print(s)

Submission status: Wrong Answer

Solution code:
import math
N, K = map(int, input().split())
#N = 100000
#K = 5
s = 0
for i in range(1,min(N, K)+1):
    s += (1/2)**(math.ceil((math.log(K) - math.log(i))/ math.log(2)))
s += (max(N, K) - K)
print(s/N)

Submission status: Wrong Answer

Solution code:
import math
#N, K = map(int, input().split())
N = 3
K = 10
s = 0
for i in range(1,min(N, K)+1):
    s += (1/N)*(1/2)**(math.ceil((math.log(K) - math.log(i))/ math.log(2)))
s += (1/N) * (max(N, K) - K)
print(s)

Submission status: Wrong Answer

Solution code:
import math
#N, K = map(int, input().split())
N = 3
K = 10
s = 0
for i in range(1,min(N, K)+1):
    s += (1/N)*(1/2)**(math.ceil((math.log(K) - math.log(i))/ math.log(2)))
s += (1/N) * (max(N, K) - K)
print(round(s, 10))

Submission status: Wrong Answer

Solution code:
import math
#N, K = map(int, input().split())
N = 3
K = 10
s = 0
for i in range(1,min(N, K)+1):
    s += (1/N)*(1/2)**(math.ceil((math.log(K) - math.log(i))/ math.log(2)))
s += (1/N) * (max(N, K) - K)
print(round(s, 9))

Submission status: Wrong Answer

Solution code:
import math
N, K = map(int, input().split())
#N = 100000
#K = 5
s = 0
for i in range(1,min(N, K)+1):
    s += (1/2)**(math.ceil((math.log(K) - math.log(i))/ math.log(2)))
s += (max(N, K) - K)
print(s/N)

Submission status: Wrong Answer

Solution code:
import math
N, K = map(int, input().split())
#N = 100000
#K = 5
s = 0
for i in range(1,min(N, K)+1):
    s += (1/N) * (1/2)**(math.ceil((math.log(K) - math.log(i))/ math.log(2)))
s += (max(N, K) - K) * (1/N)
print(s)

Submission status: Wrong Answer

Solution code:
import random

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

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

Submission status: Wrong Answer

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

import math

max_it=int(math.log(n, 2))+1
mn_d=min(d,n)
p=0

for i in range(1,mn_d+1):
	for j in range(1,max_it+1):
		if i*2**j>=n:
			if i<n:
				p+=1/d*0.5**j
			break

if d>n:
	p+=(d-n+1)/d

print(p)

Submission status: Wrong Answer

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

import math

max_it=int(math.log(n, 2))+1
mn_d=min(d,n)
p=0

for i in range(1,mn_d+1):
	for j in range(1,max_it+1):
		if i*2**j>=n:
			p+=1/d*0.5**j
			#print(j)
			break

if d>n:
	p+=(d-n+1)/d

print(p)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
log = 18
dp = [[0 for i in range(K+1)] for j in range(log)]
for i in range(1,N+1):
    if i <= K:
        dp[0][i] = 1/N
    else:
        dp[0][K] += 1/N

if  K%2 == 0:
    lim = K//2 - 1
else:
    lim = K//2
for i in range(1,log):
    j = 2
    while j <= K-1:
        dp[i][j] = dp[i-1][j//2] / 2
        j += 2
    dp[i][K] = dp[i-1][K] + sum(dp[i-1][lim+1:K-1])/2
print(dp[log-1][K])

Submission status: Wrong Answer

Solution code:
from fractions import Fraction

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

proba = 0
for i in range(1,N+1):
	deme = i
	con = 0
	while deme <= K:
		deme *= 2
		con += 1
	proba += (1/N)*((1/2)**con)

print(float(proba))

Submission status: Wrong Answer

Solution code:
from fractions import Fraction

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

fr = Fraction(1, N)
coin = Fraction(1,2)

proba = 0
for i in range(1,N+1):
	deme = i
	con = 0
	while deme <= K:
		deme *= 2
		con += 1
	proba += fr*(coin**con)

print(float(proba))

Submission status: Wrong Answer

Solution code:
from fractions import Fraction

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

fr = Fraction(1, N)
coin = Fraction(1,2)

proba = 0
for i in range(1,N+1):
	deme = i
	con = 0
	while deme <= K:
		deme *= 2
		con += 1
	proba += fr*(coin**con)

print(proba)

Submission status: Wrong Answer

Solution code:
#126
from math import ceil, log
n, k = list(map(int, input().split(' ')))
rate = 0
for i in range(1,n+1):
    if k > n:
        x = ceil(log(k/i, 2))
        rate += (1/n)*(1/2)**x
    else:
        rate += 1/n
print(rate)

Submission status: Wrong Answer

Solution code:
#126
from math import ceil, log
n, k = list(map(int, input().split(' ')))
rate = 0
for i in range(1,n+1):
    x = ceil(log(k/i, 2))
    rate += (1/n)*(1/2)**x
print(rate)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=[]
i=0
while len(a)==0 or a[-1]!=1:
    a.append((k-1)//(2**i))
    i+=1
n1=len(a)
if n>=k:
    s=(n-k+1)/n
    for i in range(n1):
        if i!=n1-1:
            s+=(a[i]-a[i+1])/(n*(2**(i+1)))
        else:
            s+=a[i]/(n*(2**(i+1)))
else:
    s=0
    for i in range(n1):
        if i!=n1-1 and a[i]>=n>a[i+1]:
            s+=(n-a[i+1])/(n*(2**(i+1)))
        elif i!=n1-1 and n>a[i+1]:
            s+=(a[i]-a[i+1])/(n*(2**(i+1)))
        elif i==n1 and n>=a[i]:
            s+=a[i]/(n*(2**(i+1)))
print(s)

Submission status: Wrong Answer

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

ans=0
l=[]

for i in range(1,n+1):
        a=i
        for j in range(0,15):
                if a<=k-1:
                        a=a*2
                else:
                        l.append(j)
                        break
for k in l:
        ans+=(1/n)*(1/2)**k
print(ans)

Submission status: Wrong Answer

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


def cal_count(num, k):
    if num >= k:
        return 0
    else:
        x = 1
        while k >= num * (2 ** x):
            x += 1
        return x


def cal_p(n):
    ans = 0
    for i in range(1, n+1):
        x = cal_count(i, k)
        ans += (1/n) * (0.5) ** x
    print(ans)

cal_p(n)

Submission status: Wrong Answer

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


def cal_count(num, k):
    if num > k:
        return 0
    else:
        x = 1
        while k >= num * (2 ** x):
            x += 1
        return x


def cal_p(n):
    ans = 0
    for i in range(1, n+1):
        x = cal_count(i, k)
        ans += (1/n) * (0.5) ** x
    print(ans)

cal_p(n)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

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

K_list = [K]
tmp = K

for i in range(1, K):
    if tmp < 1:
        break
    else:
        tmp = tmp / 2
        tmp2 = math.ceil(tmp)
        K_list.append(tmp2)

KN_list = []
count = 0

for i in range(len(K_list)):
    if K_list[i] > N :
        count += 1
        pass
    elif K_list[i] == N:
        KN_list.append(K_list[i])
    else:
        KN_list.append(K_list[i])  
if N+1 not in KN_list:
    KN_list.insert(0, N+1)

print(K_list)
print(KN_list)

ans = 0
for i in range(len(KN_list)-1):
    tmp = KN_list[i] - KN_list[i+1]
    tmp = tmp * (0.5**(i+count))
    ans += tmp

ans = ans/N

print(ans)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
if n >= k:
    ans = (n - k + 1) / n
    r_edge = k - 1
else:
    ans = 0
    r_edge = n
d = 1
while r_edge > 0:
    l_edge = k // (2 ** d)
    if r_edge > l_edge:
        ans += (r_edge - l_edge) / n / (2 ** d)
        r_edge = l_edge
    d += 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
  tmp=1
  while i*tmp < k:
    tmp*=2
    cnt+=1
  ans+=(1/3)*((1/2)**cnt)
  
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

# Xを何回Y倍したらZ以上になるか
def th(X,Y,Z):
  if abs(Y) <= 1:
    return None
  else:
    return max(0, math.ceil((math.log(Z)-math.log(X))/math.log(Y)))

result = 0
for i in range(1,N+1):
  result += (1/2)**th(i,2,K)/N
print(result)

Submission status: Wrong Answer

Solution code:
import math

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

# Xを何回Y倍したらZ以上になるか
def th(X,Y,Z):
  if abs(Y) <= 1:
    return None
  else:
    return max(0, math.ceil((math.log(Z)-math.log(X))/math.log(Y)))

result = 0
for i in range(1,N+1):
  result += (1/2)**th(i,2,K)
print(result/N)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
import math
Sum = 0
if N - K >= 0:
  Sum += N-K+1
  for i in range(1,K):
    X = math.log(K/i,2)
    if not X.is_integer():
      X = X//1 + 1
    Sum += ((1/2)**X)
else:
  for j in range(1,N):
    X = math.log(K/j,2)
    if not X.is_integer():
      X = X//1 + 1
    Sum += ((1/2)**X)
print(Sum/N)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
import math
Sum = 0
for i in range(1,N+1):
  X = math.log(K/i,2)
  if X >= 1:
    if not X.is_integer():
      X = X//1 + 1
  else:
    X = 1
  Sum += ((1/2)**X)
print(Sum/N)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
import math
Sum = 0
if N >= K:
  for i in range(1,K+1):
    X = math.log(K/i,2)
    if X >= 1:
      if not X.is_integer():
        X = X//1 + 1
    else:
      X = 1
    Sum += (1/N)*((1/2)**X)
  Sum += (N-K)/2
else:
  for i in range(1,K+1):
    X = math.log(K/i,2)
    if X >= 1:
      if not X.is_integer():
        X = X//1 + 1
    else:
      X = 1
    Sum += (1/N)*((1/2)**X)
print(Sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    N, K = list(map(int, input().split()))
    ans = 0
    for i in range(1, N+1):
        times = 0
        while(1):
            if (i * pow(2, times) > K): break
            times += 1
        ans += (1.0/N) * pow(0.5, times)

    print(ans)

main()

Submission status: Wrong Answer

Solution code:
import math

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

# 全パターン
step_1_p_list = [1 / n for x in range(1, n+1)]

# サイコロを降る回数
step_2_p_list = []

for saikoro in range(1, n+1):
    a, b = math.modf(math.log2(k/saikoro))
    # print('({}, {})'.format(a, b))
    if a == 0:
        must_win_n = b
    else:
        must_win_n = b + 1
    must_win_n = int(must_win_n)
    # print('{}: must_win_n = {}'.format(saikoro, must_win_n))
    if must_win_n < 0:
        step_2_p_list.append(1)
    else:
        step_2_p_list.append((1/2) ** must_win_n)

# print('step_1: {}'.format(step_1_p_list))
# print('step_2: {}'.format(step_2_p_list))

p_list = []

for step_1_p, step_2_p in zip(step_1_p_list, step_2_p_list):
    p_list.append(step_1_p * step_2_p)

# print('p_list: {}'.format(p_list))
ans = sum(p_list)
print(ans)

Submission status: Wrong Answer

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

ans = 0

for i in range(1,N + 1) :
    kakuritu  = 1 / N
    while i <= K :
        i = i * 2
        kakuritu = kakuritu / 2
    else :
        ans += kakuritu 

print(ans)

Submission status: Wrong Answer

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

ans = 0

for i in range(1,N + 1) :
    kakuritu  = 1
    while i <= K :
        i = i * 2
        kakuritu = kakuritu / 2
    else :
        ans += kakuritu / N

print(ans)

Submission status: Wrong Answer

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

def i(x):
    v = -ceil(log2(K / x))
    return 2 ** v

if N < K:
    l = [i for i in range(1, N + 1)]
    ans = sum(map(i, l)) / N
    print(ans)
else:
    ans = 1 - (K - 1) / (2 * N)
    print(ans)

Submission status: Wrong Answer

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

def i(x):
    v = -ceil(log2(K / x))
    return 2 ** v

l = [i for i in range(1, N + 1)]
ans = sum(map(i, l)) / N
print(ans)

Submission status: Wrong Answer

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

def i(x):
    v = -ceil(log2(K / x))
    return 2 ** v

if N  < K:
    l = [i for i in range(1, N + 1)]
    ans = sum(map(i, l)) / N
    print(ans)
else:
    ans = 1 - (K - 1) / (2 * N)
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
nk = input().split(" ");
n = int(nk[0]);
k = int(nk[1]);

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

Submission status: Wrong Answer

Solution code:
nk = input().split(" ");
n = int(nk[0]);
k = int(nk[1]);

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

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [N, K] = string_to_int(inputs[0])

    ret = 0.0
    for i in range(1, N+1):
        score = i
        count = 1
        tmp = 1.0 / N
        while score <= K:
            score *= 2
            count += 1
            tmp /= 2.0
        ret += tmp

    return ret


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Submission status: Wrong Answer

Solution code:
n, k = list(map(int, input().split()))
l = list(range(1, n + 1))

for i in l:
    if i < k:
        for r in range(1, 18):
            l[i - 1] = l[i - 1] * 2
            if l[i - 1] >= k:
                print(l[i - 1])
                l[i -1] = (1 / n) * (0.5 ** r)
                print(l[i - 1])
                break
    else:
        l[i -1] = (1 / n)
print(sum(l))

Submission status: Wrong Answer

Solution code:
import math

N,K = map(int,input().split())
sum = 0
max2 = math.ceil(math.log2(K))

for i in range(1,N+1):

    if i == K:
        sum += (2 ** max2) * (N-i+1)
        break

    R = math.ceil(math.log2(K // i))
    r = max2 - R

    sum += 2 ** r

mother = N * 2 ** max2
answer = sum/mother

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(1,N+1):
    
    if i==K:
        sum += N-i+1
        break

    R = math.log2(K // i)
    if R % 1 != 0:
        R = (R//1)+1

    sum += (1/2)**R

print(sum/N)

Submission status: Wrong Answer

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

sum_r= 0
base = 0
for i in range(N+1)[1::]:
    cnt = 0
    div_r = K//i
    if div_r == 1:
        sum_r += (2**base) * (N-i+1)
        break
    while True:
        div_r = div_r>>1
        if div_r == 0:
            if i == 1:
                base = cnt + 1
                sum_r += 1
                break
            else:
                sum_r += 2**(base - (cnt + 1))
                break
        else:
            cnt += 1
ans = sum_r / ((2**base) * N)
print(ans)

Submission status: Wrong Answer

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

sum_r= 0
base = 0
for i in range(N+1)[1::]:
    cnt = 0
    div_r = K//i
    if div_r == 1:
        sum_r += (2**base) * (N-i+1)
        break
    while True:
        div_r = div_r>>1
        if div_r == 0:
            if i == 1:
                base = cnt + 1
                sum_r += 1
                break
            else:
                sum_r += 2**(base - (cnt + 1))
                break
        else:
            cnt += 1
ans = float(sum_r) / float(((2**base) * N))
print(ans)

Submission status: Wrong Answer

Solution code:
N,K = map(int, input().split())
bi = []
i = 1
j = 0
while i < K:
    bi.append(i)
    i *= 2
    j += 1
bi.append(i)
ans = max(0,N-K)
ite = min(N+1,K)

for i in range(1,ite):
    # print(i,j, bi[j-1] * i)
    if j > 0 and bi[j-1] * i >= K:
        j -= 1
    #print(i, j, i*bi[j])
    ans += 0.5**j
print('{:.10f}'.format(ans / N))

Submission status: Wrong Answer

Solution code:
N,K = map(int, input().split())
bi = []
i = 1
j = 0
while i < K:
    bi.append(i)
    i *= 2
    j += 1
bi.append(i)
ans = max(0,N-K)
ite = min(N+1,K+1)
if N == K:
    ite = N

for i in range(1,ite):
    # print(i,j, bi[j-1] * i)
    if j > 0 and bi[j-1] * i >= K:
        j -= 1
    # print(i*bi[j], j)
    ans += 0.5**j
print('{:.10f}'.format(ans / N))

Submission status: Wrong Answer

Solution code:
N,K = map(int, input().split())
bi = []
i = 1
j = 0
while i < K:
    bi.append(i)
    i *= 2
    j += 1
bi.append(i)
ans = max(0,N-K+1)
ite = min(N+1,K+1)
if N == K:
    ite = N
# print(bi, ans, ite)
for i in range(1,ite):
    # print(i,j, bi[j-1] * i)
    if bi[j-1] * i >= K:
        j -= 1
    # print(i*bi[j], j)
    ans += 0.5**j
print('{:.10f}'.format(ans / N))

Submission status: Wrong Answer

Solution code:
N,K = map(int, input().split())
bi = []
i = 1
j = 0
while i < K:
    bi.append(i)
    i *= 2
    j += 1
bi.append(i)
ans = max(0,N-K+1)
ite = min(N+1,K+1)
for i in range(1,ite):
    # print(i,j)
    if bi[j-1] * i >= K:
        j -= 1
    ans += 0.5**j
print('{:.10f}'.format(ans / N))

Submission status: Wrong Answer

Solution code:
N,K = map(int, input().split())
bi = []
i = 1
cnt = 0
while i < K:
    bi.append(i)
    i *= 2
    cnt += 1
bi.append(i)
ans = max(0,N-K+1)
ite = min(N+1,K+1)
j = cnt
for i in range(1,ite):
    # print(i,j)
    if bi[j] * i >= K and bi[j-1] * i < K:
        ans += 0.5**j
    else:
        j -= 1
        ans += 0.5**j
print('{:.10f}'.format(ans / N))

Submission status: Wrong Answer

Solution code:

def bisect(bi, x, target, left, right):
    if left + 1 == right:
        return right
    half = (right + left) // 2
    if bi[half] * x < target:
        half = bisect(bi, x, target, half, right)
    else:
        half = bisect(bi, x, target, left, half)
    return half
N,K = map(int, input().split())
bi = []
i = 1
while i <= 10**5:
    bi.append(i)
    i *= 2
bi.append(i)

ans = 0
for i in range(1,N+1):
    if i >= K:
        ans += 1
    else:
        j = bisect(bi, i, K, 0, len(bi))
        ans += 0.5**j
        print(j)
print('{:.10f}'.format(ans / N))

Submission status: Wrong Answer

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

answer = 0

for i in range(1, n + 1):
    score = i
    coin = 0
    while 1 <= score < k - 1:
        score = score * 2
        coin += 1

    answer += (1 / n) * (0.5 ** coin)

print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N,K=map(int,input().split())
def cb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
anssub=0
for i in range(N,0,-1):
  a=0
  while i*(2**a)<K:
    a+=1
  if a-1<=N:  
    for i in range(a):
      anssub+=(1/N)*(1/2)**(a-i)
ans=1-anssub
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N,K=map(int,input().split())
def cb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
anssub=0
for i in range(N,0,-1):
  a=0
  while i*2**a<K:
    a+=1
  if a<=N:  
    for i in range(a):
      anssub+=1/N*cb(a,i)*(1/2)**(a-i+1)
ans=1-anssub
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N,K=map(int,input().split())
def cb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
anssub=0
for i in range(N,0,-1):
  a=1
  while i*2**a<K:
    a+=1
  if a<=N:  
    for i in range(a-1):
      anssub+=1/N*cb(a-1,i)*(1/2)**(a-i+1)
ans=anssub
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

ans = n - k + 1
print(ans)

for i in range(1, k):
    ans += (0.5)**(math.ceil(math.log2(k / i)))

print(ans / n)

Submission status: Wrong Answer

Solution code:
import math

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

ans = n - k + 1
print(ans)

for i in range(1, k):
    print(i)
    ans += (0.5)**(math.ceil(math.log2(k / i)))

print(ans / n)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
n_list = n
p = 0
c = 0
while k > 0.5 :
    num = max(int(n_list-k+1),0)
    if num:
        p += num * (0.5**c)
        n_list = int(k) - int(1 - ( k - int(k)))
    k /= 2
    c += 1
    print(p,n_list,k)
print( p / n )