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())

def calc(n, k):
    wa = []
    for i in range(n+2):
        wa.append(1/3 * (1/2)**i)
    
    start = math.floor((k - n) / n)
    end = math.ceil(k / n) + 1
    #print(wa[start:end])
    #print(sum(wa[start:end]))
    return sum(wa[start:end])

if N < K:
    ans = calc(N,K)
else:
    ans = ((N - K) /N)
print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import Fraction
import math
import decimal

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

decimal.getcontext().prec = 16

ans = 0

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

print(decimal.Decimal(float(ans)))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
print(0.5*(1-0.5**(int(k**0.5)))/n)

Submission status: Wrong Answer

Solution code:
a,b = map(int, input().split())
print(a, b)
prob = list()
for i in range(a):
    n = i+1
    if n >= b:
        prob.append(1)
        continue
    for j in range(b):
        c = 2 ** j
        if (n * c >= b):
            prob.append(c)
            break

probability = 0
for d in prob:
    if (d == 1):
        probability += 1 / a
    else:
        probability += 1 / (a * d)
print(probability, end='')

Submission status: Wrong Answer

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

ans=0

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

print ans

Submission status: Wrong Answer

Solution code:
N = 100000 
K = 5
prob = 0
for n in range(1, N+1):
  #print(n)
  #print("hogehoge")
  if(K <= n):
   prob = prob + 1
   continue
  else:
   #print(bin(n))
   #print(bin(K))
   len_bin_n = len(str(bin(n)))
   len_bin_k = len(str(bin(K)))
   min_rest_number_of_front = len_bin_k - len_bin_n
   if(K <= n * pow(2, min_rest_number_of_front)):
    prob = prob + 1/pow(2,min_rest_number_of_front)
    #print(1/pow(2,min_rest_number_of_front))
   else:
    prob = prob + 1/pow(2,min_rest_number_of_front+1)
    #print(1/pow(2,min_rest_number_of_front+1))

result = (1/N) * prob
print(result)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
p = []
a = 0
ans = 0


for s in range(1,N+1):
    while s < K-1:
        s = s*2
        a += 1
    p.append((N)*(2**a))
    a = 0

for i in range(N):
    ans += 1/(p[i])

print(ans)

Submission status: Wrong Answer

Solution code:
a,b = map(int, input().split())
print(a, b)
prob = list()
for i in range(a):
    n = i+1
    if n >= b:
        prob.append(1)
        continue
    for j in range(b):
        c = 2 ** j
        if (n * c >= b):
            prob.append(c)
            break

probability = 0
for d in prob:
    if (d == 1):
        probability += 1 / a
    else:
        probability += 1 / (a * d)
print(probability)

Submission status: Wrong Answer

Solution code:
import math
n = [int(e) for e in input().split()]
x=0
for i in range(1,n[0]+1):
  if(i<n[1]):
    x=x+1/(2**(math.log2(n[1]/i)//1+1))
  else:
    x=x+1
print(x/n[0])

Submission status: Wrong Answer

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

    sum = 1
    cnt = 0
    while sum < K:
        sum *= 2
        cnt += 1
    
    ans = 0
    for i in range(N):
        if cnt > 0:
            ans += (1 / N) * (0.5 ** cnt)
            cnt -= 1
        else:
            ans += (1 / N)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

n, k = map(int, input().split())
array = []
two = [pow(2, i) for i in range(20)]
#print(two)
k_tikai = 0
for j in range(len(two)):
    if k > two[j]: k_tikai = j
k_tikai += 1

for i in range(1, n+1):
    if i >= k:
        array.append(float(1)/n)
        continue
    tikai = 0
    if i in two:
        tikai = two.index(i)
    else:
        for j in range(len(two)):
            if i > two[j]: tikai = j
        tikai += 1
#    print('i:{}'.format(i))
#    print('tikai:{} value:{}'.format(tikai, two[tikai]))

    time = k_tikai-tikai
#    print(time)
    if time>0:
        array.append((float(1)/n)*pow(1/2, time))
    else:
        array.append(float(1)/n)


#print(k_tikai)
#print(two[k_tikai])

print(sum(array))

#print(array)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

import math

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

l = []
ln = n+1/2**k
l.append(math.ceil(ln-k) if ln-k>=0 else 0)
ln -= math.ceil(ln-k) if ln-k>=0 else 0

for _ in range(1,k):
    k/=2
    l.append(math.ceil(ln-k) if n-k>0 else 0)
    ln-=math.ceil(ln-k) if n-k>0 else 0
    if k<=1:
        break

print(l)
ans = 0
for i in range(len(l)):
    ans += l[i]/n/2**i
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import math
N, K = map(int, input().split())
ans = 0
for i in range(N):
  if i >= K:
    ans += 1/N
  else:
    ans += 1/N*pow(0.5, len(bin(math.floor(K/(i+1))))-2)

print(ans)

Submission status: Wrong Answer

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

b = k // 2
d = 0

for i in range(n):
  c = i + 1
  if c >= k:
    d += 1 / n
    continue
  for j in range(k):
    c *= 2
    if c >= k:
      d += (0.5 ** (j+1)) / n
      break

Submission status: Wrong Answer

Solution code:
import math
N,K = map(int,input().split(" "))
LOOPER = math.ceil(math.log2(K))
P = 0
for i in range(N):
    DI = i+1
    j = 1
    SCORE = 0
    while True:
        SCORE = DI * 2**j
        #print(SCORE)
        if SCORE >= K:
            break
        j += 1
    if j == 1:
        P += float((N-DI)/N)
        #print(float((N-DI)/N))
        break
    else:
        P += float(1/N) * float(1/2**j)
    #print(P)
print(P)

Submission status: Wrong Answer

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

c_2times = []
for i in range(N):
    c_2times.append(0)

prob_list = []
for d in range(1, N+1):
    point = d
    while True:
        if (point > K):    #(1 <= point <= K-1)
            break
        point *= 2
        c_2times[d-1] += 1
    prob_list.append(1/N + (1/2)**c_2times[d-1])

prob_sum = 0
for i in range(len(prob_list)):
    #print(prob_list[i])
    prob_sum += prob_list[i]

print(prob_sum/100)

Submission status: Wrong Answer

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



def kaisuu():

	a = 0
	b = 1

	while True:
		b = b*2
		a+=1 
		if b > k:
			break
			
	return a
			
max_count = kaisuu()

kakuritu = 0
for _ in range(0,n):

	kakuritu += 1/3 * pow(1/2,max_count)
	max_count-=1
	if max_count == 0:
		break
	
print(kakuritu)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,K = map(int, input().split())
ans = 0
logK = np.log2(K)
if N < K:
    for i in range(N):
        sisu = int(logK - np.log2(i + 1))
        if np.log2(K/(i+1)) != int(np.log2(K/(i+1))):
            sisu += 1
        ans +=1 / (2 ** sisu)
    print(ans/ N)
else:
    for i in range(K - 2):
        sisu = int(logK - np.log2(i + 1))
        if np.log2(K/(i+1)) != int(np.log2(K/(i+1))):
            sisu += 1
        ans +=1 / (2 ** sisu)   
    ans += N - K + 1
    ans = ans / N
    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):
  if i>= k:
    ans += 1 / n
  else:
    ans += np.power(1 / 2, np.ceil(np.log2(k / i))) / 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:
    ans += 0.5**int(math.log(k/i, 2))
  else:
    ans += 1
    
print(ans/n)

Submission status: Wrong Answer

Solution code:
import math

n,k = 3,10#map(int, input().split())

ans = 0

if n <= k:

    for i in range(1,n+1):
        a = k//int(i)
        ex = int(math.log2(a)) + 1
        ans += (1/n)*(0.5**ex)

    print(ans)

else:

    for i in range(1,k):
        a = k//int(i)
        ex = int(math.log2(a)) + 1
        ans += (1/n)*(0.5**ex)
    
    ans += (n-k+1)/n
    print(ans)

Submission status: Wrong Answer

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

prob = [0] * N

for i in range(1,N+1):
    tmp = i
    for j in range(1,K):
        tmp *= 2
        if tmp >= K:
            prob[i-1] = 1/N * ((1/2)**j)
            break

ans = 0
for i in range(N):
    ans += prob[i]

print(ans)

Submission status: Wrong Answer

Solution code:


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

S = 0

for i in range(1,N+1):
    T = i
    c = 1
    while True:
        if T > K:
            c = 0
            break
        if(T * 2 < K):
            T *= 2
            c += 1
        else:
            break
    S += 0.5 ** c

S /= N
print('{:.10f}'.format(S))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

a,b=input().split()
P=[]
for x in range(int(a)):
    v=math.log2(int(b)/(x+1))
    if isinstance(v,int):
        y=int(v)
    elif int(v)>1:
        y=math.floor(v+1)
    elif int(v)==0:
        y=0
        
    P.append(1/int(a)*pow(2,-y))


print(sum(P))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
from decimal import Decimal, getcontext
getcontext().prec = 40
n, k = map(int, input().split())

# 1/nは最後に全部にかける
if k>=n:
    prob = Decimal('0')
else:
    prob = Decimal(str((n-k+1)*2))

list_prob = []
if k>=n:
    for i in range(1,n+1):
        list_prob.append(int(math.log2(k/i))+1)

    for num in list_prob:
        prob = prob + Decimal('0.5')**Decimal(str(num-1))
else:
    for i in range(1,k):
        list_prob.append(int(math.log2(k/i))+1)
    for num in list_prob:
        prob = prob + Decimal('0.5')**Decimal(str(num-1))

prob = prob / Decimal(str(n)) / Decimal('2')
print(prob)

Submission status: Wrong Answer

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

c_2times = []
for i in range(N):
    c_2times.append(0)

prob_list = []
for d in range(1, N+1):
    point = d
    while True:
        if (point > K):    #(1 <= point <= K-1)
            break
        point *= 2
        c_2times[d-1] += 1
    prob_list.append(1/N + (1/2)**c_2times[d-1])

prob_sum = 0
for i in range(len(prob_list)):
    print(prob_list[i])
    prob_sum += prob_list[i]

print(prob_sum)

Submission status: Wrong Answer

Solution code:
import math

def coins(n,k):
    p = 0
    for l in range(1,min(k, n+1)):
        p += (0.5)**math.ceil(math.log2(k / l))
    return p


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

if k <= n:
    Pwin += (n-k+1) /n
    Pwin += ((k-1)*coins(n,k))/n
else:
    Pwin += coins(n,k) /n

print(Pwin)

Submission status: Wrong Answer

Solution code:
import math

n, k = [int(c) for c in input().split()]

def main():
    if n == 1 and k == 1:
        print(1.0)
        return
    else:
        ans = 0

    if n == 1:
        dice = math.log2(k)
        print(1 / 2**dice)
        return
    for i in range(1, n+1):
        dice = int(math.log2(k / i) + 1)
        if i >= k:
            ans += 1 / n
            continue
        ans += (1 / n) * (1 / 2**dice)
    print(ans)

main()

Submission status: Wrong Answer

Solution code:
import math

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) * 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:
import sys
import math
from decimal import Decimal
input = sys.stdin.readline

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

power_list =[] 
K_flag = N
K_temp = K

if N > K:
    power_list.append(N-K+1)
    K_flag = K-1
else:
    power_list.append(0)

while K_temp >= 1:
    power_list.append(0)
    K_temp /= 2
    if K_temp <= K_flag:
        power_list[-1] += K_flag - math.floor(K_temp)
        K_flag = math.floor(K_temp)

percentage_sum = Decimal("0.0")

for i in range(len(power_list)):
    dec_temp = math.pow(1.0/2,i)
    dec_temp = Decimal(str(dec_temp)) / Decimal(str(N))
    percentage_sum += power_list[i] * dec_temp

print(percentage_sum)

Submission status: Wrong Answer

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

sum=0

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

print(sum/n)

Submission status: Wrong Answer

Solution code:
import math

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

wa = []
#確率の算出
#ダイスの目が出る確率
dice = 1/n
#コインの表が出る確率
coin = 1/2
#すべてのサイコロの目について
for i in range(1, n+1):
    #k点を超えるためにさいころをふる数
    cnt = math.ceil(math.log(k/i, 2))
    #確率算出
    p = coin * cnt * (1/n)
    wa.append(p)
print(sum(wa)/10)

Submission status: Wrong Answer

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

i = 1
temp = 1
# count decide
count = 0
def countt(temp):
    count = 0
    while temp <= k:
        temp *= 2
        count += 1

    return count

a = 0

while i <= n:
    if i < k:
        count = int(countt(i))
        s = (1/n * ((1/2)**count))
        i += 1
        a += s
        count -= 1
    else:
        a += 1/n
        i += 1
print(a)

Submission status: Wrong Answer

Solution code:
import sys
import math
 
a,b=map(int, input().split())
 
probablity = 0.0
 
for i in range(a + 1):
  ceil = math.ceil(math.log(b / (i + 1)))
  if(ceil < 0):
    ceil = 0
  elif(ceil < 1):
    ceil = 1
    
  probablity = probablity + 1 / (a * 2 ** ceil)
  
print(probablity)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
import math
def main():
  input = sys.stdin.readline
  N, K =map(int,input().split())
  p = []
  for d in range(1,N+1):
    if d >= K:
      p.append(1/N)
    else:
      n = math.floor(np.log2(K/d)) + 1
      p.append( 1/N * 1/2 ** n)
  print(sum(p))
main()

Submission status: Wrong Answer

Solution code:
import math


def input_from_console():
    n, k = map(int, input().split())
    return n, k


def main():
    n, k = input_from_console()
    probability = 0.0
    if k == 1:
        probability = 1.0
    elif n == 1:
        probability = pow(1 / 2, math.ceil(math.log2(k)))
    elif n > k:
        probability += ((n - (k - 1)) + 1) / n
        for i in range(2, k):
            # print(i, pow(1 / 2, i) / n)
            x = math.ceil(math.log2(k))
            probability += pow(1 / 2, x) / n
    elif n < k:
        x = math.ceil(math.log2(k))
        for i in range(2, x + 1):
            print(i)
            probability += pow(1 / 2, i) / n
    else:
        probability = 1/n
        for i in range(1, k):
            # print(i, 1/n * pow(1/2, math.ceil(math.log2(k))))
            probability += 1/n * pow(1/2, math.ceil(math.log2(k)))
            # probability += pow(1 / 2, i) / n

    print(probability)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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


for i in range(1,N+1):
    if K>i:
        count.append((1/N)*((1/2)**(1+int(math.log2(K/i)))))
    elif K<=i:
        no_count.append(1/N)
    else:
        print(1/0)
print(sum(count)+sum(no_count))

Submission status: Wrong Answer

Solution code:
import math
n,k = map(int, input().split())
ans = 0
if n>=k:
    ans += 1-k/n
iterate = k if n>k else n
for i in range(1,iterate+1):
    temp = math.log2(k/i)
    temp = int(temp) if temp%1==0 else int(temp)+1
    ans += (1/n)*math.pow(0.5,temp)
    print(temp)
print(ans)

Submission status: Wrong Answer

Solution code:
import decimal

N ,K = (int(i) for i in input().split())
ans = 0
for i in range(int(N)):
  c = float(1)
  while (i+1)*(2**c) < K:
    c = c + 1
  if c == 1:
    ans = ans + 1/N
  else:
    ans = ans + ((1/2)**c)/N

print(ans)

Submission status: Wrong Answer

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


if __name__ == '__main__':
    [n, k] = li()

    # 最初の目がk以上で勝つ確率
    win1 = max(0, (n - k + 1))
    # print(win1)

    # コインを投げる最大回数
    coin_max_num = len(bin(k)) - 2
    win_list = []
    candidate_list = []

    for coin in range(1, coin_max_num + 1):
        if coin == 1:
            upper = min(n, k)
            candidate = max(upper - (k + 2 ** coin - 1) // 2 ** coin, 0)
        else:
            upper = min(n, (k + 2 ** coin - 1) // 2 ** coin)
            candidate = max(upper + 1 - (k + 2 ** coin - 1) // 2 ** coin, 0)
        # print(upper)
        candidate_list.append(candidate)
        # print(candidate)
        # print()

        win_list.append(max(0, candidate * 0.5 ** coin))
    # print(win_list)
    print((win1 + sum(win_list)) / (n))

    # upper = min(n, k)
    # win_list.append(max(0, (upper - (k + 2**1-1) // 2) / n) * 0.5 ** 1)

    # upper = min(n, (k + 1) // 2)
    # win_list.append(max(0, (upper - (k+2**2-1) // 2**2) / n) * 0.5 ** 2)
    # print(99996 / 100000 + 2 / 100000 * 0.5 + 1 / 100000 * 0.5 ** 2 + 1 / 100000 * 0.5 ** 3)

Submission status: Wrong Answer

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

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

print(prob)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
dice = 1 / n
ans = []
for i in range(1,n+1):
    if i >= k:
        ans.append(dice)
    else:
        k1 = i
        count = 0
        while k >= k1:
            k1 = k1 * 2
            count += 1
        ans.append(dice * (0.5 ** count))
print(sum(ans))

Submission status: Wrong Answer

Solution code:
import math
n,k = map(int, input().split())
ans = 0
if n>=k:
    ans += 1-k/n
iterate = k if n>k else n
for i in range(1,iterate+1):
    temp = math.log2(k/i)
    temp = int(temp) if temp%1==0 else int(temp)+1
    ans += (1/n)*math.pow(0.5,temp)
    print(temp)
print(format(ans, '.20f'))

Submission status: Wrong Answer

Solution code:
import math


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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import math

n, k = list(map(int, input().split()))
p = 0
for i in range(1, n + 1):
    if i >= k:
        p += 1.0
    else:
        p += math.pow(2, -math.ceil(math.log(k, i + 1)))
print(p / n)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
import math

N,K=map(int,input().split())
prob = [0]*N


for ii in range(1,N+1):
    index = math.ceil(np.log2(K/ii))
    if index <= 1:
        prob[ii-1] = 1/N
    else:
        prob[ii-1] = 1/N * (1/2)**index

print(sum(prob))

Submission status: Wrong Answer

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

if N >= K:
    ans2 = (1/N) * (N - K-1)
    now = 1
    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,K-1):
        A.append(A[i-1]*2)
    print(sum(A)+ans2)
else:
    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())
beki2 = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072]
P = 0
for i in range(min(N,K-1)):
    for j, b2 in enumerate(beki2):
        if K/(i+1) < b2:
            P += 1./float(N)*0.5**(j+1)
            break
if N > K-1:
    P += 1./float(N)*float(N-K+1)
print(P)

Submission status: Wrong Answer

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


ans = 0

def calc(i):
    bb = 1
    while i * (2 ** bb) <= K:
        bb +=1    
    return bb

for i in range(1, N + 1):
    if i >= K:
        ans += 1 / N
    else:
        y = calc(i)
        ans += 1 / N * (1/2)**y

print(ans)

Submission status: Wrong Answer

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

n, k = map(int, input().split())
probability = 0
result = 0
for i in range(n):
    score = i + 1
    for j in range(14):
        if score > k:
            break
        score *= 2
    result += Fraction(1, 2**j)

print(float(result * Fraction(1, n)))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import math
n, k = map(int, input().split())

ans = 0
for i in range(1, n + 1):
    if i < k:
        quotient = k / i
        base = int(math.log2(k / i)) + 1
        ans = ans + (1 / (2 ** base) / n)
    else:
        ans = ans + 1 / n

print(ans)

Submission status: Wrong Answer

Solution code:
from decimal import *

nk = input()
nk = nk.split(' ')
nk = [int(a) for a in nk]
n = nk[0]
k = nk[1]

r = 0

def get_fact(n):
    ret = 1
    for i in range(n):
        ret *= 2
    return ret

for i in range(n):
    current = i + 1
    count = 0
    while(current <= k):
        count += 1
        current *= 2
    else:
        r += (1/n) * (1/get_fact(count))

print(r)

Submission status: Wrong Answer

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

sum = 0

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

print(sum)

Submission status: Wrong Answer

Solution code:
import numpy as np
from fractions import Fraction

n, k = [np.array(elem, dtype=np.int) for elem in input().split()]
prob = 0

for i in range(1, n+1):
    tmp = int(np.log2(k/i))
    if tmp <= 0:
        prob += 1/n
    else:
        num = tmp + 1
        prob += (1/n) * (1/2 ** num)
print(prob)

Submission status: Wrong Answer

Solution code:
import math
N, K = input().split(" ")
N, K = int(N), int(K)
P = 0
if (N < K):
  for n in range(1,N+1):
    P += 1/(N*pow(2,math.ceil(math.log2(K)-math.log2(n))))
else:
  for n in range(1, K):
    P += 1/(N*pow(2,math.ceil(math.log2(K)-math.log2(n))))
  P += (N-K)/N
print(P)

Submission status: Wrong Answer

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

tmp = k
count = 0
while tmp > 1:
  tmp = tmp / 2
  count += 1

ret = 0
for i in range(1, n+1):
  goal = pow(2, count) * i
  offset = 0
  if i >= k:
    ret += (1/n)
  else:
    while goal > k:
      goal = goal / 2
      offset += 1
    offset = count - 1 if offset == 0 else offset - 1
    a = (1 / n) * pow(0.5, count - (offset))
    ret += a
print(ret)

Submission status: Wrong Answer

Solution code:
import math


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

Submission status: Wrong Answer

Solution code:
from fractions import Fraction
import math
import decimal

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

decimal.getcontext().prec = 16

ans = 0

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

print(decimal.Decimal(float(ans)))

Submission status: Wrong Answer

Solution code:
import math
N,K=map(int,input().split())
count=[]
no_count=[]
if N<K:
    print(0)
    exit()

for i in range(1,N+1):
    if K>i:
        count.append((1/N)*((1/2)**(1+int(math.log2(K/i)))))
    else:
        no_count.append(1/N)
print(sum(count)+sum(no_count))

Submission status: Wrong Answer

Solution code:
#coding: utf-8
from math import log, log2
N, K = map(int, input().split())
cnt = 0
for n in range(1, N+1):
	if n < K:
		#x = int((log(K/n)) / (log(2))) + 2
		x = int(log2(K/n)) + 1
		#print("n = {}, x = {}".format(n, x))
		cnt += (0.5 ** x) * (1 / N)
	else:
		cnt += (1 / N)

print(cnt)

Submission status: Wrong Answer

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

sum_prob = 0
count = math.floor(math.log2(k)) + 1 

if count < k:
    print(1-1/n)
else:
    for i in range(2, count+1):
        sum_prob += (1/n) * (1/2)**i
    print(sum_prob)

Submission status: Wrong Answer

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

n, k = map(int, input().split())
array = []
two = [pow(2, i) for i in range(15)]
#print(two)
k_tikai = 0
for j in range(len(two)):
    if k > two[j]: k_tikai = j
k_tikai += 1

for i in range(1, n+1):
    if i >= k:
        array.append(float(1)/n)
        continue
    tikai = 0
    if i in two:
        tikai = two.index(i)
    else:
        for j in range(len(two)):
            if i > two[j]: tikai = j
        tikai += 1
#    print('i:{}'.format(i))
#    print('tikai:{} value:{}'.format(tikai, two[tikai]))

    time = k_tikai-tikai
#    print(time)
    if time>0:
        array.append((float(1)/n)*pow(1/2, time))
    else:
        array.append(float(1)/n)


#print(k_tikai)
#print(two[k_tikai])

print(sum(array))

#print(array)

Submission status: Wrong Answer

Solution code:
import math

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

out=0
for n in range(1,N+1):
    d=math.log2(K/n)
    if d <= 0:
        d=0
    else :
        d =int(d)+1
    
    out+=(1/N)*(1/2)**d
print(out)

Submission status: Wrong Answer

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

def get_n(num, K):
    score = num
    for i in range(20):
       if score > K:
           return i
       score = score * 2

for i in range(1, N+1):
    n = get_n(i, K)
    i_score = (1/N) * ((1/2)**n)
    result += i_score

print(result)

Submission status: Wrong Answer

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

import math
Ans = 0

if K < N:
    for X in range(1, K+1):
        R = math.log(K/X, 2)
        S = math.ceil(R)
        Ans = Ans + (0.5**S / N)
    Ans = Ans + (N-K)/N
    print(Ans)

if K == N:
    for X in range(1, K+1):
        R = math.log(K/X, 2)
        S = math.ceil(R)
        Ans = Ans + (0.5**S / N)
    Ans = Ans + 1/N
    print(Ans)
    
if K > N:
    for X in range(1,N+1):
        R = math.log(K/X, 2)
        S = math.ceil(R)
        Ans = Ans + (0.5**S / N)
    print(Ans)

Submission status: Wrong Answer

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

import math
P = 0
for i in range(1,N+1):
    P += (0.5)**(math.ceil( math.log2(float(K/i)) ))
print(P)
print(P/N)

Submission status: Wrong Answer

Solution code:
# cook your dish here
import math

def power(x, y): 
  
    if(y == 0): return 1
    temp = power(x, int(y / 2))  
      
    if (y % 2 == 0): 
        return temp * temp 
    else: 
        if(y > 0): return x * temp * temp 
        else: return (temp * temp) / x 
        
        
n,k=map(int,input().split())
summ=0
for i in range(1,n+1):
    value=0
    if i<k:
        y=k//i
        value=math.log(y,2)
        value=int(value)
        value+=1
    po=power(0.5,value)
    summ+=po
    
summ=summ/n
print('{0:.12f}'.format(summ))

Submission status: Wrong Answer

Solution code:
from math import log10, ceil

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

res = 0
for i in range(1, n + 1):
    if i < k:
        tmp = ceil(((log10(k) - log10(i * 2)) / log10(2)) + 1)
        res += (1 / (n * (2 ** tmp)))
    else:
        res += 1/n
print(res if k != 1 else 1)

Submission status: Wrong Answer

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

p = 1
while p <= k:
    p = p << 1
pb = (p >> 1)-1
if pb == 0:
    pb = 1
c = n - k + 1
if c <= 0:
    c = 0

# print(pb)
# print(p)
# print(c)

print((pb + p * c) / p / n)

Submission status: Wrong Answer

Solution code:
import math
n,k=list(map(int,input().split()))
a=0
for i in range(1,n+1):
  ex=math.ceil(math.log2(k/i))
  print(ex)
  a+=(1/2)**(ex)
  if n>=k:
    break
print(a/n)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
p = []
a = 0
ans = 0


for s in range(1,N+1):
    while s < K-1:
        s = s*2
        a += 1
    p.append((1/N)*((1/2)**a))
    a = 0

for i in range(N):
    ans += p[i]

print(ans)

Submission status: Wrong Answer

Solution code:
from decimal import*
getcontext().prec = 28

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

preans = 0

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

ans = Decimal(preans / n)
print(ans)

Submission status: Wrong Answer

Solution code:
from decimal import *

import math

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

# 計算しない範囲を求める
# 100 10 なら 100-10 + 1/100はかつ

result =0
if N > K:
    #print(Decimal((N-K)/N))
    #result = Decimal((N-K+1)/N)
    result = Decimal((N-K)/N)

for i in range(1,min(N,K) + 1):
    #print(i)
    #print(1/2 ** i)
    #print(Decimal((1 / N ) * ((1/2) ** (i+1) )))
    #result += Decimal((1 / N ) * ((1/2) ** (i+1) ))
    #result += Decimal(1 / (N * (2 ** (i))))
    #print(N * (2 ** i))
    beki = 0
    if i == 1:
        beki = int(math.log(K,i * 2)) +1
        #print('a' , beki)
    elif  math.log(K,i) > 1:
        beki = int(math.log(K,i))
        #print('b',beki)

    #print(int(math.log(K,i * 2)))
    result += Decimal((1 / (N * (2 ** beki))))
    #print(Decimal(1 / (N * (2 ** (i)))))
print(result)