Problem:


Score : 300 points

Problem Statement

Snuke has a fair N-sided die that shows the integers from 1 to N with equal probability and a fair coin. He will play the following game with them:

Throw the die. The current score is the result of the die.

As long as the score is between 1 and K-1 (inclusive), keep flipping the coin. The score is doubled each time the coin lands heads up, and the score becomes 0 if the coin lands tails up.

The game ends when the score becomes 0 or becomes K or above. Snuke wins if the score is K or above, and loses if the score is 0.

You are given N and K. Find the probability that Snuke wins the game.

Constraints

1 ≤ N ≤ 10^5

1 ≤ K ≤ 10^5

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K

Output

Print the probability that Snuke wins the game. The output is considered correct when the absolute or relative error is at most 10^{-9}.

Sample Input 1

3 10

Sample Output 1

0.145833333333

If the die shows 1, Snuke needs to get four consecutive heads from four coin flips to obtain a score of 10 or above. The probability of this happening is \frac{1}{3} \times (\frac{1}{2})^4 = \frac{1}{48}.

If the die shows 2, Snuke needs to get three consecutive heads from three coin flips to obtain a score of 10 or above. The probability of this happening is \frac{1}{3} \times (\frac{1}{2})^3 = \frac{1}{24}.

If the die shows 3, Snuke needs to get two consecutive heads from two coin flips to obtain a score of 10 or above. The probability of this happening is \frac{1}{3} \times (\frac{1}{2})^2 = \frac{1}{12}.

Thus, the probability that Snuke wins is \frac{1}{48} + \frac{1}{24} + \frac{1}{12} = \frac{7}{48} \simeq 0.1458333333.

Sample Input 2

100000 5

Sample Output 2

0.999973749998



Sample input:
3 10


Sample output:
0.145833333333

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
a, b = (int(_) for _ in input().split())  
res = float(sum([(1/2 ** (math.ceil(int(b/i)**(1/2)))) if i < b else 1 for i in range(1,a+1)]) / a)
print(res)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
s=0
for n in range(N):
    score=n+1
    cnt=0
    while score<10:
        score*=2
        cnt+=1
    e=1/N*(1/2)**cnt
    if score >=K:
        s+=e
print(s)

Submission status: Wrong Answer

Solution code:
import math

n, k = map(int, raw_input().split(" "))

if n > k:
    base = float(n - k + 1) / float(n)
else:
    base = 0

sum = base

for i in range(1, min(k, n + 1)):
    l = math.ceil(math.log(float(k) / float(i), 2))
    # print("i=%d l=%d" % (i, l))
    sum += (1.0 / float(n)) * (0.5 ** l)

print("%.9f" % sum)

Submission status: Wrong Answer

Solution code:
N,K=map(int, input().split())
ans=max(0.0,(N+1-K)/N)
r=K-1
p=1.0
i=1
import math
while True:
    l=min(r,math.ceil(K/(i*2)))
    p/=2
    if r<N:
        print(p,r,l)
        ans+=p*(r+1-l)/N
    elif l<=N:
        print(p,N,l)
        ans+=p*(N+1-l)/N
    if r==1:
        break
    r=l-1
    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):
    if N >= K:
        ans += 1
    else:
        loop = 0
        tmp = i
        while True:
            tmp *= 2
            loop += 1
            if tmp > K:
                break
        # print(1/N)
        # print(loop)
        # print((1/2)**loop)
        ans += 1/N * (1/2)**loop
print(ans)

Submission status: Wrong Answer

Solution code:
def per(first, point):
    if first >= point:
        return 1
    i = 1
    c = first
    while (c <= point):
        c = c * 2
        i = i * 0.5
    return i

line = [int(x) for x in input().split(' ')]

dice = line[0]
win = line[1]

vals = [per(x, win) / dice for x in range(1, dice + 1)]
print(sum(vals))

Submission status: Wrong Answer

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

per = 0
for i in range(1,n+1):
    p = i
    t = 0
    
    while(p < 10):
        t += 1
        p = p*2
#        print(i,p,t)
    
    if(t == 0):
        t = 0
#        print(i,p,t)

        
    per +=1/n * (1/2 ** t)
    
print("{:.9}".format(per))

Submission status: Wrong Answer

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

    ans = 0
    dice = 1
    
    while dice <= min(N,K):
        p = 1/N
        score = dice
    
        while score < K:
            score *= 2
            p /= 2
        
        ans += p
        dice += 1
        
    print ("%.10f" % (ans))
    
if __name__ == "__main__":  
    solve()

Submission status: Wrong Answer

Solution code:
def pows(n, K):
    count = 1
    while True:
        n = n * 2
        if n >= K:
            return count
        count += 1


def main():
    N, K = list(map(int, input().split()))
    re = max(N - K, 0)
    for i in range(1, min(K, N)):
        if i >= K :
            break
        p = pows(i, K)
        re = re + float( 0.5 ** p)
    print(float(re / N))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
N,K = map(int,input().split())
Z = []
a = 2 ** (math.floor(K ** (1/N))) * N
for i in range(N):
  Z += [1/a]
  a = a * 2
sum = 0
for b in Z:
  sum += b
print(sum)

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(15):
        if i >= k:
            break
        i *= 2
    ans += 1 / (n * 2 ** j)
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:
        ee=math.ceil((math.log(k)-math.log(i))/math.log(2))
        ans+=(1/2)**ee
    else:
        ans+=1.0
print(ans/n)

Submission status: Wrong Answer

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

print(ans/n)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().rstrip().split(' '))
result = 0.0

for i in range(N):
    current = i + 1
    for j in range(1, 20):
       if current >= N:
           result += (1/2)**(j+1) * 1/N
           break
       current *= 2

print(result)

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
s = 0
for n in range(1, N+1):
    if (n < K):
        nn = math.floor(math.log2(K/n)) + 1
        s += 1/N * (1/2)**nn
    else:
        s += 1 / N

print(s)

Submission status: Wrong Answer

Solution code:

# coding: utf-8

# In[41]:

import sys
input = sys.stdin.readline
N, K = map(int, input().split())
#S = input()


# In[20]:

import math


# In[46]:

print(N, K)


# In[47]:

sum_ = 0
R = min(N, K)
clear = N-K+1 if N>=K else 0
R = R-1 if N>=K else R
#print('R = {}'.format(R))
for i in range(R):
    #print(math.ceil(math.log(K/(i+1), 2)))
    sum_ += (1/2) ** math.ceil(math.log(K/(i+1), 2))


# In[48]:

#print(clear/N)
print(1/N*sum_ + clear/N)


# In[ ]:

Submission status: Wrong Answer

Solution code:
import math

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

tsum=0

for x in range(1,N+1):
	if(x==1):
		logarithm=math.ceil(math.log(K,2))
	else:
		logarithm=math.ceil(math.log(K/x,2))
	tsum+=(1/(N*pow(2,logarithm)))

print(tsum)

Submission status: Wrong Answer

Solution code:
import math
N,K = map(int,input().split())
ans = 0
for i in range(1,N+1):
      X = K / i
      Y = math.log(X,2)
      Y_int = int(Y) + 1
      if i < K:
        Z = 1 / N * (0.5 ** Y_int)
        ans += Z
      else:
        ans += 1 / N

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

total = 0
for i in range(1, n+1):
    
    cnt = 0
    temp = i
    while temp < 10:
        temp *= 2
        cnt += 1
    
    power = math.pow(2, -cnt) / n
    total += power
    #print(i, cnt, power)


print(total)

Submission status: Wrong Answer

Solution code:
import math

order = input().split()
face = int(order[0])
goal = int(order[1])

probability = 0

#何もしなくても勝つ確率
if face >= goal:
    probability += (face-goal+1)/face

#goal以下の数字が出た時はgoalまでコインを振る
up = goal+1 if face>= goal else face+1
for i in range(1,up):
  kaisu = int(math.log2(goal/i) + 1)
  probability += 1/face*(1/2)**kaisu

print(probability)

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:
  	c = math.ceil((math.log(K) - math.log(i)) / math.log(2))
  	a = 1 / 2 ** c / N
  	ans += a
  else:
    ans += 1 / N
print(ans)

Submission status: Wrong Answer

Solution code:
N,K=map(int, raw_input().split())
kiso=float(1)/N

ans=0

if N<K:
	loop=N+1
elif N>K:
	loop=K
else:
	loop=K

for n in range(1, loop):
	cnt=0
	while n<=K:
		n*=2
		cnt+=1
	ans+=kiso/(2**cnt)

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

print ans

Submission status: Wrong Answer

Solution code:
miu = input().split()

qurare = []

for x in range(int(miu[0])):
	if (x+1) >= int(miu[1]):
		qurare.append(1/int(miu[0]))
		continue

	delphine = 1
	while True:
		if (x+1) * pow(2, delphine) > int(miu[1]):
			qurare.append(1/int(miu[0]) * pow(0.5, delphine))
			break
		delphine += 1

print(sum(qurare))

Submission status: Wrong Answer

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


for i in range(n, 0, -1):
    if(k % n == 0): count = k // n
    else: count = k // n + 1

    if(i == n):
        j = 1
        while(i**(j+1) < k): j += 1

        ans = 1 / (n*2**j)
    else:
        while(i**(j+1) >= k): j -= 1
        j += 1

        ans += 1 / (n*2**j)

print(ans)

Submission status: Wrong Answer

Solution code:
import math
N,K = map(int,input().split())
list2 = []
tmp = 1
while tmp < 10 ** 5 + 1:
    list2 += [tmp]
    tmp *= 2

L2 = len(list2)
ans = 0
for i in range(1,N+1):
    tmp = math.ceil(K/i)
    
    for j in range(L2):
        if tmp <= list2[j]:
            break
    ans += list2[j] ** (-1)
ans /= N
print(ans)

Submission status: Wrong Answer

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

prob=0

for i in range(1,N+1):
    j=1
    count=0
    while(True):
        if(i*j>K):
            prob+=(1/N)*((1/2)**count)
            break
        else:
            j*=2
            count+=1

print(prob)

Submission status: Wrong Answer

Solution code:
def main():
	N, K = map(int, input().split())
	dp = [0 for _ in range(K+1)]
	prob = 1/N

	if K > N:
		for i in range(1, N+1):
			dp[i] = prob
	else:
		for i in range(1, K+1):
			dp[i] = prob
		dp[K] += prob*(N-K)

	ans = dp[K]
	for i in range(1, min(N+1, K)):
		cur = i
		this_p = dp[i]
		while cur <= K:
			this_p *= 0.5
			cur *= 2
		ans += this_p
	print(ans)

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
import math

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

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

print(ans)

Submission status: Wrong Answer

Solution code:

N, K = map(int, input().split())
def keta(f):
    s = str(f)
    if s.find('.') < 0:
        return -1
    else:
        return len(s.split('.')[1])
    
prob = 0
for i in range(N):
    n = N - i
    n2 = n
    count = 0
    while True:
        if n2 >=K:
            break
        count+=1
        n2 = n2*2
#     print(n, n2, count, (1/N) * pow(0.5, count))
    ans = (1/N) * pow(0.5, count)
    if keta(ans) >= 12:
        break
    else:
        prob += ans

print(prob)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
import math
N ,K=map(int ,raw_input().split())

C = []
for i in range(N):
    C.append(int(math.ceil(np.log2(K)-np.log2(i+1))))
P = 0.000
C.sort()
k =C[0]
t = 0
p = 0.5**(k-1)
#print(C)
for n in C:
    if k != n:
        p=p/2
        P+=p*t
        #print p*t,n,p,t
        t = 1
    else:
        t +=1
P+=p/2*t
#print p*t,n,p,t
#print P
print (P/N)

Submission status: Wrong Answer

Solution code:
import math

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

P = float()
for i in range(1, N + 1):
    n = math.ceil(math.log2(K/i))
    if n < 0:
        continue

    p = 1 / (N * 2 ** n)
    #print(i, n, p)
    P += p

print(P)

Submission status: Wrong Answer

Solution code:
#C
import math
N, K = map(int, input().split())
p = 0.0
for d in range(1, N+1):
    if d >= K:
        p += 1.0 / N
    else:
        c = int(math.log(K/d, 2)) + 1
        p += (1/2)**c / N
print(p)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, K] = [int(input_raw[0]), int(input_raw[1])]

    ans = 0.0
    if K == 1:
        print 1
        return
    for x in range(1, N + 1):
        #t = (K)/(2 * (x)) + (1 if (K)%(2 * (x)) == 0 else 0)
        t = math.ceil(math.log(float(K)/float(x), 2))
        if t == 1.0:
            break
        ans += (1.0/(2 ** t))/float(N)
    ans += float(N - x)/float(N)
    print ("%20.15f" % ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

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

ans =0.0000000000

if n>=k:
    ans += (n-k+1)/n
    for i in range(k-1):
        ans += (1/n)*math.pow(1/2, int(math.log2(k/(i+1)))+1)
else:
    for i in range(n):
        ans += (1/n)*math.pow(1/2, int(math.log2(k/(i+1)))+1)

print(ans)

Submission status: Wrong Answer

Solution code:
from math import log,ceil
def solve():
    N,K = map(int, input().split())
    if N == 1 and K != 1:
        print("0")
        exit()

    ans = 0
    for x in range(1, N+1): # xは初期値
        kaisuu = ceil( log( K / x, 2))
        tmp = 1
        for i in range(kaisuu):
            tmp *= 0.5
        ans += tmp 
    ans /= N
    print(ans)
        

    
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

preans = 0

cs = 1 #2の-cs乗との比較
for i in range(n):
    if n - i < k:
        while float(1 /(2**cs)) >= float((n - i) / k):
            cs = cs + 1
        preans = preans + float(1 / (2**cs))
    else:
        preans = preans + 1

ans = preans * float(1 / n)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K=map(int, raw_input().split())
kiso=float(1)/N

ans=0

if N<K:
	loop=N+1
elif N>K:
	loop=K
else:
	loop=K

for n in range(1, loop):
	cnt=0
	while n<=K:
		n*=2
		cnt+=1
	ans+=kiso/(2**cnt)

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

print ans

Submission status: Wrong Answer

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

sum1 = 0
for i in range(n):
    cnt = 0
    s = i + 1
    if s >= k:
        sum1 += 1/n
    else:
        while True:
            s *= 2
            cnt += 1
            if s > k:
                break
        sum1 += 1/n * 0.5**cnt
    
print(sum1)

Submission status: Wrong Answer

Solution code:
import math
N, K = map(int, input().split())
if N >= K :
    print(1.0)
else :
    total = 0.0
    for n in range(1,N+1) :
        total += (1.0 / N) * 0.5 ** math.ceil(math.log2(1.0 * K / n))
    print(total)

Submission status: Wrong Answer

Solution code:
import math 

n,k = map(int,input().split(" "))
result = 0.0

for i in range(1,n+1):
    if i >= k:
        max_pow = 0.0
    else:
        max_pow = math.floor(math.log(k/i)/math.log(2)) + 1
    result += (0.5) ** max_pow /n
print(result)

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# coding: utf-8

import math

def main():
    n, k = list(map(int, input().split()))
    cand = []
    tk = k
    tn = n
    while tk > 0.5:
        if int(tk) == tk:
            cand.append(max(0, tn-tk+1))
            tn = tk-1
        else:
            cand.append(max(0, tn-int(tk)))
            tn = int(tk)
        tk /= 2
    ans = sum(cand[i] / pow(2, i) for i in range(len(cand)))
    print(ans/n)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

sum=0
for deme in range(1,N+1):
    need_challenge=max(0,math.ceil((math.log(K)-math.log(deme))/math.log(2)))
    sum+=float((1/N)*((1/2)**need_challenge))
print('{:.13f}'.format(sum))

Submission status: Wrong Answer

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

if K == 1:
  print(float(1))
  
prob = []

for i in range(1, N+1):
  if i >= K:
    prob.append(1/N)
  else:
    prob.append(round(1/N * 0.5 ** (math.ceil(math.log(K/i)/math.log(2))), 12))
  
print(sum(prob))

Submission status: Wrong Answer

Solution code:
import math
N,K = map(int,input().split())
Z = []
a = 2 ** (math.floor(K ** (1/3))) * N / 2
for i in range(N):
  a = a * 2
  Z += [(1/a)]
sum = 0
for b in Z:
  sum += b
print(sum)

Submission status: Wrong Answer

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

ka = 0

for i in range(1, n+1):
    
    j = 1
    while(1):
        if (i * (2 ** j)) >= k:
            break
        
        j += 1
    
    ka += 1/n * ((1/2)**j)
    
print(ka)

Submission status: Wrong Answer

Solution code:
from math import log, ceil

N, K = tuple([int(x) for x in input().split(' ')])

M = min(N, K)
ans = sum([0.5 ** ceil((log(K) - log(n)) / log(2)) / float(N) for n in range(1,M+1)])
ans += (1 / float(N)) * max(N-K, 0)

print(ans)

Submission status: Wrong Answer

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

dice_max = N
goal = K



dice = list(range(1, dice_max+1))

import math

ans = 0
    
for d in dice:
    win = 1
    if d < goal:
        lose_num = math.ceil(math.sqrt(goal // d))
        win = 1 / (2** lose_num)
        
    ans += win

ans /= len(dice)
print('{:.15g}'.format(ans))

Submission status: Wrong Answer

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

point = 1/float(N)
coin = 0.5
win = 0
for i in range(N):
  if(K == 1):
    win = 1.0
    break
  if(i+1 >= K):
    win += point
  else:
    tmp = coin
    j = 1
    while ((i + 1) * pow(2,j) <= K):
      tmp = tmp * coin
      j += 1
    win += point * tmp
print(win)

Submission status: Wrong Answer

Solution code:
from decimal import Decimal
from math import log2, ceil
N, K = list(map(int, input().strip().split()))
r = max(N - K, 0)

t = Decimal(0)
d = Decimal(N)
for i in range(1, N-r+1):
    tmp = 1/d * (Decimal(0.5) ** Decimal(ceil(log2(K/i))))
    t += 1/d * (Decimal(0.5) ** Decimal(ceil(log2(K/i))))

if r > 0:
    t += Decimal(1) - Decimal(N-r) / Decimal(r)

print(str(t))

Submission status: Wrong Answer

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

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


for i in range(1,min(k,n+1)):
    temp = 1/n
    tval = k/i
    p = int(math.log(tval,2))+1
    ans +=temp*(0.5**p)
print(ans)

Submission status: Wrong Answer

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

sum1 = 0
for i in range(n):
    cnt = 0
    s = i + 1
    if s > k:
        sum1 += 1/n
    else:
        while True:
            s *= 2
            cnt += 1
            if s > k:
                break
        sum1 += 1/n * 0.5**cnt
    
print(sum1)

Submission status: Wrong Answer

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

now = N
count = 0
while True:
    if now >= K:
        break
    now *= 2
    count += 1

ans = (1/N) * (0.5) ** count

A = [ans]

for i in range(1,N):
    A.append(A[i-1]*0.5)

print(sum(A))

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(15):
        if i >= k:
            break
        i *= 2
    ans += (1 / n) * (1 / 2) ** j
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from math import log2, ceil
from collections import defaultdict
from decimal import Decimal, getcontext

getcontext().prec = 11

input = sys.stdin.readline

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

d = defaultdict(int)



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

    if die < K:
        d[ceil( log2( K/die ) )] += 1

    else:
        d[0] += 1

print(d)

cumulative = 0

for power in d:
    current = d[power]
    for _ in range(power):
        current /= 2

    cumulative += current

# print('{:.10f}'.format(cumulative / N))
# print(cumulative / N)

ans = Decimal(cumulative / N)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math

a = []
for l in sys.stdin:
    a.append(l)

_input = a[0]

n = int(_input.split()[0])
k = int(_input.split()[1])

each_result = max(n-k+1, 0) * (1/n)

for each_n in range(1, min(n+1, k)):
    each_time = int(math.ceil(k/each_n))
    each_result += 1/n * (1/2) ** each_time

print(each_result)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

def get_x(n, K):
    if n >= K:
        return 0
    else:
        x_raw = (np.log(K, dtype=np.float64) - np.log(n, dtype=np.float64))/np.log(2, dtype=np.float64)
        return np.ceil(x_raw)

def get_prob(n, K):
    x = get_x(n, K)
    if x == 0:
        return 1
    else:
        return (1/2)**x
    
ans = np.mean([get_prob(n, K) for n in range(1, N+1)], dtype=np.float64)

print('{0:.12f}'.format(ans))

Submission status: Wrong Answer

Solution code:

N, K = map(int, input().split())
def keta(f):
    s = str(f)
    if s.find('.') < 0:
        return -1
    else:
        return len(s.split('.')[1])
    
prob = 0
for i in range(N):
    n = N - i
    n2 = n
    count = 0
    while True:
        if n2 >=K:
            break
        count+=1
        n2 = n2*2
#     print(n, n2, count, (1/N) * pow(0.5, count))
    ans = (1/N) * pow(0.5, count)
    if keta(ans) >= 11:
        break
    else:
        prob += ans

print(prob)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, K] = [int(input_raw[0]), int(input_raw[1])]

    ans = 0.0
    for x in range(1, N + 1):
        #t = (K)/(2 * (x)) + (1 if (K)%(2 * (x)) == 0 else 0)
        t = math.ceil(math.log(float(K)/float(x), 2))
        if t == 1.0:
            break
        ans += (1.0/(2 ** t))/float(N)
    ans += float(N - x)/float(N)
    print ("%20.15f" % ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
N_1 = N
p, ans = 1, 0
while True:
  if N > K * p:
    B = math.ceil(K * p)
    s = N - B + 1
    ans += s * p
    N -= s
  if N == 0:
    break
  p /= 2
print(ans/N_1)

Submission status: Wrong Answer

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

sum=0
cnt=0
for i in range(1,n+1):
    if i>=k:
        cnt+=1
    else:
        sum+=1/(2**(int(np.log2(k//i))+1))
sum=sum+cnt
print(sum/n)

Submission status: Wrong Answer

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

r = 0
for n in range(1, N + 1):
	c, t = 0, n
	while t <= K:
		t <<= 1
		c += 1
	#print(c)
	r += 1 / N * (1 / 2) ** c
print(r)

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
s = 0
for n in range(1, N+1):
    nn = math.floor(math.log2(K/n)) + 1
    s += 1/N * (1/2)**nn

print(s)

Submission status: Wrong Answer

Solution code:
import math

order = input().split()
face = int(order[0])
goal = int(order[1])

probability = 0

#何もしなくても勝つ確率


#goal以下の数字が出た時はgoalまでコインを振る
for i in range(1,face+1):
  if face >= goal:
    probability += (face-goal+1)/face
  else:
    kaisu = int(math.log2(goal/i) + 1)
    probability += 1/face*(1/2)**kaisu

print(probability)

Submission status: Wrong Answer

Solution code:
import sys
import math 
import numpy as np
ni = lambda: int(ns())
na = lambda: list(map(int, input().split()))
ns = lambda: input()
N,K=na()
n=N
k=10**9
cnt=0

while(N<K):
    #print(N,K)
    K=math.ceil(K/2)
    cnt+=1
k=K

ans=0
first=True
while(True):
    if(first):
        ans+=(N-k+1)*(0.5**cnt)
        first=False
    else:
        ans+=(N-k)*(0.5**cnt)

    #print("ddd",(N-k+1)*(0.5**cnt),"N",N,"k",k,"n-k+1",N-k+1,"cnt",cnt)
    #print("ans",ans)
    cnt+=1
    N=k
    k=math.ceil(k/2)
    #print("k",k)
    if(k==1):
        ans+=1*(0.5**cnt)
        #print("ddd",1*(0.5**cnt))
        #print("cnt",cnt)
        break
#print(ans,n)
ans=ans/n
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0

for i in range(n):
    i += 1
    if i == 1:
        t = int(math.log2(k)) + 1
    else:
        t = int(math.log(k, i))
    ans += (1 / n) * (1 / 2) ** t

print(ans)

Submission status: Wrong Answer

Solution code:
a,b=tuple(map(int,input().split()))
cnt=0
for i in range(1,a+1):
    q=i
    cont=0
    while True:
        q*=2
        cont+=1
        if q>=b:
            break
    cnt+=1/a*(1/2)**cont
    
print(cnt)

Submission status: Wrong Answer

Solution code:
import math
n,k=map(int,input().split(" "))
if k<=n:#最初にk以上を出す確率
  p=n-k+1
else:
  p=0
#0を1度も引かない場合勝てる。
for i in range(min(n,k-1)):#0~k-2
  x=int(math.log2(k/(i+1)))+1
  p+=(0.5)**x
print(p/n)

Submission status: Wrong Answer

Solution code:
import math
from decimal import *
N,K = [int(x) for x in input().split()]
ans = 0
lk = math.log(K)
l2 = math.log(2)
for i in range(1,N+1):
    if(i>=K):
        ans+=1
        continue
    else:
        l = (lk-math.log(i))/l2
        if(not int(l)==l):
            l = int(l)+1
        else: l = int(l)
        ans += Decimal(0.5**l)
print(ans/N)

Submission status: Wrong Answer

Solution code:
import math
N,K = map(int,input().split())
cnt = 0
for n in range(1,N+1):
    if K/n <= 1:
        x = 0
    elif math.log(K/n)%math.log(2)==0:
        x = int(math.log(K/n)/math.log(2))
    else:
        x = int(math.log(K/n)/math.log(2))+1
    cnt += (0.5)**x

print(cnt/N)

Submission status: Wrong Answer

Solution code:
import math

order = input().split()
face = int(order[0])
goal = int(order[1])

probability = 0

#何もしなくても勝つ確率


#goal以下の数字が出た時はgoalまでコインを振る
for i in range(1,face+1):
  if face >= goal:
    probability += (face-goal+1)/face
    print('Check!')
  else:
    print(i)
    kaisu = int(math.log2(goal/i) + 1)
    print(kaisu)
    probability += 1/face*(1/2)**kaisu

print(probability)

Submission status: Wrong Answer

Solution code:
n, k = map(int,input().split())
start = k // 2 - 1
sum = 0
for i in range(n):
    sum += (1/3) * ((0.5)**start)
    if start >= 2:
        start -= 1
    else:
        break
print(sum)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
ans = max((n - k + 1) / n, 0)
for a in range(1, min(k, n + 1)):
    ans += 0.5 ** (k // a).bit_length() / n
print('{:.12f}'.format(ans))

Submission status: Wrong Answer

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

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

print(p)

Submission status: Wrong Answer

Solution code:
n, k = map(int,input().split())
start = k // 2 - 1
sum = 0
for i in range(n):
    print(start)
    sum += (1/3) * ((0.5)**start)
    if start >= 2:
        start -= 1
    else:
        break
print(sum)

Submission status: Wrong Answer

Solution code:
#Xの目が出た時、1/2のceil(log2(K/X))乗の確率でうまくいく
import math
N,K=map(int,input().split())
print(sum([
    (1/2)**math.ceil(math.log2(K)-math.log2(x))
    for x in range(1,N+1)])/N)

Submission status: Wrong Answer

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

point = 1/float(N)
coin = 0.5
win = 0
for i in range(N):
  if(i+1 >= K):
    win += point
  else:
    tmp = coin
    j = 1
    while ((i + 1) * pow(2,j) <= K):
      tmp = tmp * coin
      j += 1
    win += point * tmp
print(win)

Submission status: Wrong Answer

Solution code:
import sys
import math

a = []
for l in sys.stdin:
    a.append(l)

_input = a[0]

n = int(_input.split()[0])
k = int(_input.split()[1])

each_result = max(n-k+1, 0) * (1/n)

for each_n in range(1, min(n+1, k)):
    each_time = int(math.log2(k-0.001/each_n)) + 1
    each_result += 1/n * (1/2) ** each_time

print(each_result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import bisect
import decimal

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

k2 = k
a = []

while k2 >= 1:
    a.append(k2)
    k2 = int(k2 / 2)

a.sort()
l = len(a)

ans = decimal.Decimal(0)
for i in range(1, n + 1):
    if i < k:
        e = bisect.bisect_left(a, i)
        ans += decimal.Decimal(0.5**(l - e))
    else:
        ans += decimal.Decimal(1)

print(decimal.Decimal(ans / n))

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0
for i in range(1, n+1):
    temp = math.log2(k / i)
    if abs(temp - int(temp)) > 0.0000000001:
        temp = int(temp) + 1
    ans += (0.5 ** temp)
ans = ans / n
print(ans)

Submission status: Wrong Answer

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

sum=0
for deme in range(1,N+1):
    need_challenge=max(0,math.ceil((math.log(K)-math.log(deme))/math.log(2)))
    sum+=(1/N)*((1/2)**need_challenge)
print(sum)

Submission status: Wrong Answer

Solution code:
import math
N, K = [int(item) for item in input().split()]
ans = 0
for i in range(1, N+1):
  tmp = i
  cnt = 0
  while tmp <= K:
    tmp *= 2
    cnt += 1
  ans += 1 / (N * 2 ** cnt)
print(ans)

Submission status: Wrong Answer

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

sum=0
for deme in range(1,N+1):
    need_challenge=max(0,math.ceil((math.log(K)-math.log(deme))/math.log(2)))
    sum+=(1/N)*((1/2)**need_challenge)
    print(need_challenge)
    print((1/N)*((1/2)**need_challenge))
print(sum)

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0
for i in range(1, n+1):
    temp = math.log2(k / i)
    if abs(temp - int(temp)) > 0.00000001:
        temp = int(temp) + 1
    ans += (0.5 ** temp)
ans = ans / n
print(ans)

Submission status: Wrong Answer

Solution code:
import math

n, k = map(int, input().split())
ans = 0.0
for i in range(1, n+1):
    if i >= k:
        ans += (n-k+1)/n
        break
    else:
        tmp = math.ceil(math.log(k, i+1))
        ans += (1/n) * ((1/2)**(tmp))
print(ans)