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())
pro = 0
if math.log2(k) % 1 == 0:
  if n < k:
    for i in range(1,n+1):
      if k/i % 2 == 0:
        x = int(math.log2(k/i))
      else:
        x = int(math.log2(k/i)) + 1
      coin = 2**x
      pro += (1/n) * (1/coin)
  if n >= k:
    pro += (n-k+1)/n
    for j in range(1,k):
      if k/j % 2 == 0:
        x = int(math.log2(k/j))
      else:
        x = int(math.log2(k/j)) + 1
      coin = 2**x
      pro += (1/n) * (1/coin)
if math.log2(k) % 1 > 0:
  if n < k:
    for i in range(1,n+1):
      x = int(math.log2(k/i)) + 1
      coin = 2**x
      pro += (1/n) * (1/coin)
  if n >= k:
    pro += (n-k+1)/n
    for j in range(1,k):
      x = int(math.log2(k/j)) + 1
      coin = 2**x
      pro += (1/n) * (1/coin)
print(pro)

Submission status: Wrong Answer

Solution code:
import math
n, k = map(int, input().split())
pro = 0
if n < k:
  for i in range(1,n+1):
    if k/i % 2 == 0:
      x = int(math.log2(k/i))
    else:
      x = int(math.log2(k/i)) + 1
    coin = 2**x
    pro += (1/n) * (1/coin)
if n >= k:
  pro += (n-k+1)/n
  for j in range(1,k):
    if k/j % 2 == 0:
      x = int(math.log2(k/j))
    else:
      x = int(math.log2(k/j)) + 1
    coin = 2**x
    pro += (1/n) * (1/coin)
print(pro)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
import math
# コインを連続i回表出さないといけないサイコロの目
# n >= k ならi=0

i=1
ans=max(0,(n-k+1)/n)

while k*2**(-i+1) > 1:
    a = min(n,math.floor(k*2**(-i+1)))
    b = math.ceil(k*2**(-i))
    ans+=max(a-b+1,0) * 2**(-i) /n
    i+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
import math
# コインを連続i回表出さないといけないサイコロの目
# n >= k ならi=0

i=1
ans=max(0,(n-k+1)/n)

while k*2**(-i+1) >= 1:
    a = min(n,math.floor(k*2**(-i+1)))
    b = math.ceil(k*2**(-i))
    ans+=max(a-b+1,0) * 2**(-i) /n
    i+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
import math
# コインを連続i回表出さないといけないサイコロの目
# n >= k ならi=0

i=1
ans=max(0,(n-k+1)/n)

while k*2**(-i+1) >= 1:
    a = min(n,math.floor(k*2**(-i+1)))
    b = math.ceil(k*2**(-i))
    ans+=max(a-b+1,0) * 2**(-i) /n
    i+=1
print(round(ans,13))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import collections, math, bisect
from fractions import Fraction

local = False
if local:
    file = open("input.txt", "r")
    import time

def inp():
    if local:
        return file.readline().rstrip()
    else:
        return input().rstrip()

def ints():
    return [int(_) for _ in inp().split()]

if local:
    start=time.time()


N, K = ints()

oneprob = Fraction(1, N)
ans = 0
for i in range(1, N+1):
    if i>=K:
        break
        
    doubling_amounts = math.ceil(math.log2(K/i))
    ans+=Fraction(1,2)**doubling_amounts

ans*=oneprob

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

print("{:.20f}".format(float(ans)))

if local:
    fin = (time.time()-start)*1000
    print("{:.2f}".format(fin) + "ms")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
n,k=map(int,input().split())
l=0
for i in range(1,n+1):
    if k>i and math.log2(k/i)==n:l+=(0.5**n)/n
    else: l+= (0.5**((math.log2(k/i)//1) +1))/n
print(l)

Submission status: Wrong Answer

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

def maxcount(n,k):
    if n>=K:
        return k
    else:
        k+=1
        return maxcount(2*n,k)
    
for i in range(1,N+1):
    if i<K:
        ans+=(1/N)*((1/2)**maxcount(i,0))
        print(maxcount(i,0))
    else:
        ans+=1/N
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n, k = map(int, input().split())
pro = 0
if n < k:
  for i in range(1,n+1):
    x = int(math.log2(k/i)) + 1
    coin = 2**x
    pro += 1/ (n*coin)
if n >= k:
  pro += (n-k+1)/n
  for j in range(1,k):
    x = int(math.log2(k/j)) + 1
    coin = 2**x
    pro += 1/ (n*coin)
print(pro)

Submission status: Wrong Answer

Solution code:
def main():
    import math
    n,k = map(int,input().split())
    p = 0
    for i in range(1,n+1):
        if k>i:
            p += 0.5**(int(math.log2(k/i))+1)
        else:
            p += 1
    print(p/n)
            
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

for i in range(n):
  tmp = 1 / n
  now = 1
  while now < k:
    now *= 2
    tmp /= 1/2
  n_sum += tmp
print(n_sum)

Submission status: Wrong Answer

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

def min_cnt(n, k):
  res = 2
  cnt = 1
  while k > res:
    cnt += 1
    res *= 2*n
  return cnt

if n < k:
  for i in range(n):
    num = k/2 - (i + 1)
    n_sum += (1/n) * ((1/2) ** num)
else:
  for i in range(k - 1):
    num = k//2 + 1 - (i + 1)
    n_sum += (1/n) * ((1/2) ** num)
  n_sum += (n - k + 1) / n

print(n_sum)

Submission status: Wrong Answer

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

def min_cnt(n, k):
  res = 2
  cnt = 1
  while k > res:
    cnt += 1
    res *= 2*n
  return cnt

if n < k:
  for i in range(n):
    num = k/2 - (i + 1)
    n_sum += (1/n) * ((1/2) ** num)
else:
  for i in range(k - 1):
    num = k//2 + 1 - (i + 1)
    n_sum += (1/n) * ((1/2) ** num)
  n_sum += (n - k + 1) / n

print(n_sum)
print(5//2)

Submission status: Wrong Answer

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

def min_cnt(n, k):
  res = 2
  cnt = 1
  while k > res:
    cnt += 1
    res *= 2*n
  return cnt

if n < k:
  for i in range(n):
    num = k/2 - (i + 1)
    n_sum += (1/n) * ((1/2) ** num)
else:
  for i in range(k - 1):
    num = k/2 - (i - 0.9475)
    n_sum += (1/n) * ((1/2) ** num)
  n_sum += (n - k + 1) / n

print(n_sum)

Submission status: Wrong Answer

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

def min_cnt(n, k):
  res = 2
  cnt = 1
  while k > res:
    cnt += 1
    res *= 2*n
  return cnt

if n < k:
  for i in range(n):
    num = k/2 - (i + 1)
    n_sum += (1/n) * ((1/2) ** num)
else:
  for i in range(k - 1):
    num = k/2 - (i -1)
    n_sum += (1/n) * ((1/2) ** num)
  n_sum += (n - k + 1) / n

print(n_sum)

Submission status: Wrong Answer

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

def min_cnt(n, k):
  res = 2
  cnt = 1
  while k > res:
    cnt += 1
    res *= 2*n
  return cnt

if n < k:
  for i in range(n):
    num = k/2 - (i + 1)
    n_sum += (1/n) * ((1/2) ** num)
else:
  for i in range(k - 1):
    num = k/2 - (i)
    n_sum += (1/n) * ((1/2) ** num)
  n_sum += (n - k + 1) / n

print(n_sum)

Submission status: Wrong Answer

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

def min_cnt(n, k):
  res = 2
  cnt = 1
  while k > res:
    cnt += 1
    res *= 2*n
  return cnt

if n < k:
  for i in range(n):
    num = k/2 - (i + 1)
    n_sum += (1/n) * ((1/2) ** num)
else:
  for i in range(k - 1):
    num = k/2 - (i + 1)
    n_sum += (1/n) * ((1/2) ** num)
  n_sum += (n - k) / n

print(n_sum)

Submission status: Wrong Answer

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

def min_cnt(n, k):
  res = 2
  cnt = 1
  while k > res:
    cnt += 1
    res *= 2*n
  return cnt

if n < k:
  for i in range(n):
    num = k/2 - (i + 1)
    n_sum += (1/n) * ((1/2) ** num)
else:
  for i in range(k - 1):
    num = k/2 - (i + 1)
    n_sum += (1/n) * ((1/2) ** num)
  n_sum += (n - k - 1) / n

print(n_sum)

Submission status: Wrong Answer

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

for i in range(1, n + 1):
    if i >= k:
        result += (n - i) / n
        break
    else:
        count = 1
        while i * (2 ** count) < k:
            count += 1
        result += (1. / n) * (1 / 2) ** count
print(result)

Submission status: Wrong Answer

Solution code:
import math

inputted = list(map(int, input().split()))
N = inputted[0]
K = inputted[1]

num_of_rolls = lambda dice, K: math.ceil(math.log2(K / dice))
continuous_probability = lambda rolls: (1 / 2) ** rolls
expectation = lambda N: 1 / N

answer = 0
for dice in range(1, N + 1):
    num = num_of_rolls(dice, K)
    # print(dice, num)
    answer += continuous_probability(num)
answer *= expectation(N)

print(answer)

Submission status: Wrong Answer

Solution code:
import math

inputted = list(map(int, input().split()))
N = inputted[0]
K = inputted[1]

num_of_rolls = lambda dice, K: math.ceil(math.log2(K / dice))
continuous_probability = lambda rolls: (1 / 2) ** rolls
expectation = lambda N: 1 / N

answer = 0
for dice in range(1, N + 1):
    num = num_of_rolls(dice, K)
    print(dice, num)
    answer += continuous_probability(num)
answer *= expectation(N)

print(answer)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
answer = 0
for x in range(1, N+1):
    y = 0
    while True:
        if x * 2 ** y > K:
            break
        y += 1
    answer += (.5) ** y

answer /= N
print(answer)

Submission status: Wrong Answer

Solution code:
import math
n, k = [int(i) for i in input().split()]
sum = 0
for i in range(1, n+1):
    k = 1
    while i * (2 ** k) <= 10:
        k += 1
    sum += 1 / (2 ** k * n)
print(sum)

Submission status: Wrong Answer

Solution code:
input_num = input().split()
dice_num = int(input_num[0])
border_socre = int(input_num[1])
ans_p = 0

for score in range(1,dice_num + 1):
    coin_counter = 0
    while score < border_socre:
        score = score * 2
        coin_counter += 1
        print(coin_counter)
    ans_p += (1 / dice_num ) * ((1/2 ) ** coin_counter)
    
print(ans_p)

Submission status: Wrong Answer

Solution code:
input_num = input().split()
dice_num = int(input_num[0])
border_socre = int(input_num[1])
ans_p = 0

for score in range(1,dice_num + 1):
    coin_counter = 0
    
    while score <= border_socre:
        score = score * 2
        coin_counter += 1
    ans_p += (1 / dice_num ) * (1/2 ) ** coin_counter
print(ans_p)

Submission status: Wrong Answer

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

ans = 0
for i in range(1,n+1):
    count = 0
    if i < k:
        while i <= k:
            i *= 2
            count += 1
    ans += 1/n * (1/2)**count
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
    if i < k-1:
        while i < k:
            i *= 2
            count += 1
    ans += 1/n * (1/2)**count
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
    if i < k-1:
        while True:
            if i >= k:
                break
            i *= 2
            count += 1
    ans += (1/n) * (1/2)**count
print(ans)

Submission status: Wrong Answer

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

p = 0
for i in range(1, N+1):
    c = 0
    while 1 <= i < K-1:
        i *= 2
        c += 1
    p += (1/N)*((1/2)**c)
print(p)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

result = 0
for n in range(1, N + 1):
  base_point = n

  point = base_point * 2
  count = 1

  while point < K:
    point *= 2
    count += 1
  
  result += (1/N) * pow(0.5, count)

print(result)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
k-=1
b=[]
for i in range(1,n+1):
  b.append(len(str(format(k//i, 'b'))))

if n>=k:
  for i in range(k-1,n):
    b[i]=0
d=[0]*(b[0]+1)
for i in range(n):
  d[b[i]]+=1
c=[1]
for i in range(b[0]):
  c.append(c[i]/2)
ans=0
for i in range(len(c)):
  ans+=d[i]*c[i]

print(ans/n)

Submission status: Wrong Answer

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

ans = 0

if N >= K:
    ans += (N - K + 1) / N
    L = K-1
    print(N-K+1)
else:
    L = N
#print(ans)

rate = 0
for i in range(1,L+1,1):
    #print(i)
    score = i
    c = 0
    
    while score < K:
        score = score * 2
        c += 1
    r = 2** c
    #print(c)
    rate += 1/r
    
    #print(ans)
ans += (1/N) * rate

print(ans)

Submission status: Wrong Answer

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

ans = 0

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


rate = 0
for i in range(1,L+1,1):
    score = i
    c = 0
    
    while score <= K:
        score = score * 2
        c += 1
    r = 2** c
    rate += 1/r
    
    #print(ans)
ans += (1/N) * rate

print(ans)

Submission status: Wrong Answer

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

ans = 0

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



for i in range(1,L+1,1):
    ans_i = 0
    score = i
    c = 0
    
    while score <= K:
        score = score * 2
        c += 1
    rate = (1 / N)*((1/2)** c)
    ans += rate
    #print(ans)

print(ans)

Submission status: Wrong Answer

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

ans = 0

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



for i in range(1,L+1,1):
    ans_i = 0
    score = i
    rate = 1 / N
    while score <= K:
        score = score * 2
        rate = rate * (1/2)
    ans += rate
    #print(ans)

print(ans)

Submission status: Wrong Answer

Solution code:
import math
n,k=map(int,input().split())
now=k
cnt=0 #割った回数
ans=max(0,n-k+1)
while now>=1:
    a=now/2
    b=math.ceil(a) #最小値
    if now!=int(now):
        c=int(now) #最大値
    else:
        c=int(now)-1
    cnt+=1
    print(a,b,c,cnt)
    if b>min(k-1,n): #調べる最大値(K-1かNの小さいほう)が最小値より大きいとき
        now=a
        continue
    elif c>min(k-1,n): #最大値より小さいとき
        c=min(k-1,n) #最大値を補正
    ans+=1/(2**cnt)*(c-b+1)
    now=a
    if now==1:
        break
print(ans/n)

Submission status: Wrong Answer

Solution code:
import math
n,k=map(int,input().split())
now=k
cnt=0 #割った回数
ans=max(0,n-k+1)
while now>=1:
    a=now/2
    b=math.ceil(a) #最小値
    c=int(now) #最大値
    cnt+=1
    if b>min(k-1,n): #調べる最大値(K-1かNの小さいほう)が最小値より大きいとき
        now=a
        continue
    elif c>min(k-1,n): #最大値より小さいとき
        c=min(k-1,n) #最大値を補正
    ans+=1/(2**cnt)*(c-b+1)
    now=a
print(ans/n)

Submission status: Wrong Answer

Solution code:
import math
n,k=map(int,input().split())
now=k
cnt=0 #割った回数
ans=max(0,n-k+1)
while now>=1:
    a=now/2
    b=math.ceil(a) #最小値
    c=int(now) #最大値
    cnt+=1
    print(a,b,c,cnt)
    if b>min(k-1,n): #調べる最大値(K-1かNの小さいほう)が最小値より大きいとき
        now=a
        continue
    elif c>min(k-1,n): #最大値より小さいとき
        c=min(k-1,n) #最大値を補正
    ans+=1/(2**cnt)*(c-b+1)
    now=a
print(ans/n)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def f(j,k):
  for i in range(1,10000):
    if j**(i+1)>=k:
      return i
    if j==1 and (j+1)**i>=k:
      return i    
for j in range(1,n+1):
  if j>=k:
    ans+=1
  else:
    ans+=0.5**f(j,k)
#  print(j,f(j,k),0.5**f(j,k),ans)
print(ans/n)

Submission status: Wrong Answer

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

for i in range(1,n+1):
    score = i
    rate = 1/n
    while(score < 10):
        rate *= (1/2)
        score  *= 2
    rate_total.append(rate)

print(sum(rate_total))

Submission status: Wrong Answer

Solution code:
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()
    ret = 0
    for n in range(1, N - 1):
        t = 1
        while n * t < K:
            t *= 2
        ret += 1 / t

    print(ret / N)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()
    pp = 2
    ret = 0
    for n in range(N):
        pp *= 2
        ret += (1 / pp) * (1 / N)

    print(ret)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

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

p = 0
for i in range(1,N+1):
    if i >= K:
        p += (N-K-1)/N
        break
    else:
        p += 1/N * ((0.5)**math.ceil(math.log2(K/i)))
        # print((0.5)**math.ceil(math.log2(K/i)))

print(p)

Submission status: Wrong Answer

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

p = 0
for i in range(1,N+1):
    if i >= 10:
        p += (N-10+1)/N
        break
    elif i in [5,6,7,8,9]:
        p += (1/N) * (1/2)
    elif i in [3,4]:
        p += (1/N) * ((1/2)**2)
    elif i == 2:
        p += (1/N) * ((1/2)**3)
    elif i == 1:
        p += (1/N) * ((1/2)**4)

print(p)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
now = 1
p = 0
p_sum = 0
for i in range(1,N+1):
  now = i
  p = 1
  for j in range(10**5):
    now *= 2
    if now >= K:
      p *= 0.5
      p_sum += p
      break
    else:
      p *= 0.5
print(p_sum/N)

Submission status: Wrong Answer

Solution code:
import math
n, k = map(int, input().split())
pro = 0.0
for p in range(1, n + 1):
    if p >= k:
        pro += 1.0 / n
    else:
        a = 1 + int(math.log2(k / p))
        pro += (1.0 / n) * (0.5**a)
print("{:.15f}".format(pro))

Submission status: Wrong Answer

Solution code:
import math
n, k = map(int, input().split())
pro = 0.0
for p in range(1, n + 1):
    if p >= k:
        pro += 1 / n
    else:
        a = 1 + int(math.log2(k / p))
        pro += (1 / n) * (0.5**a)
print("{:.15f}".format(pro))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
import numpy as np
N, K=map(int, input().split())
if N>=K:
  p1=(N-K+1)/N
  klist=list(range(1,K))
else:
  p1=0
  klist=list(range(1,N+1))

def calc(x):
  y=math.ceil((np.log(K)-np.log(x))/np.log(2))
  p=((0.5)**y)
  
  return p

plist=list(map(calc, klist))
p2=sum(plist)/N
print(p2+p1)

Submission status: Wrong Answer

Solution code:
import math
import numpy as np
N, K=map(int, input().split())
if N>=K:
  p1=(N-K)/N
  klist=list(range(1,K))
else:
  p1=0
  klist=list(range(1,N+1))

def calc(x):
  y=math.ceil((np.log(K)-np.log(x))/np.log(2))
  p=((0.5)**y)
  
  return p

plist=list(map(calc, klist))
p2=sum(plist)/N
print(p2+p1)

Submission status: Wrong Answer

Solution code:
import math

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

Pro = 0

for i in range(1, N+1):
    try:
        count = math.ceil(math.log2(K // i))
        if count < 0:
            count = 0

    except ValueError:
        count = 0

    Pro += ((0.5) ** count) / N

print(Pro)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

n, k = map(int, input().split())
ans = []
for i in range(1, n+1):
    if i < k:
        cnt = 0
        while i < k:
            i *= 2
            cnt += 1
        tmp = 1/n * ((1/2) ** cnt)
        ans.append(tmp)
        print((1/2) ** cnt, tmp)
print(math.floor(sum(ans) * 10 ** 10) / (10 ** 10))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
ans=0
for i in range(1,N+1):
    score=i
    cnt=0
    while(K>=score):
        score=score*2
        cnt+=1
    ans+=(0.5**cnt)/N
print("{:.12f}".format(ans))

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
ans=0
for i in range(1,N+1):
    score=i
    cnt=0
    while(K>=score):
        score=score*2
        cnt+=1
    ans+=(1/N)*(0.5**cnt)
print("{:.12f}".format(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(1, N + 1):
  cnt = 0
  S = i
  while S <= K:
    cnt += 1
    S *= 2
    
  E += 0.5 ** cnt
  
print(E / N)

Submission status: Wrong Answer

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

for i in range(1, N + 1):
  cnt = N + 2 - i 
  E += 0.5 ** cnt
  
print(E / N)

Submission status: Wrong Answer

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

for i in range(1, N + 1):
  cnt = N + 2 - i 
  E += 1 / (2 ** cnt)
  
print(E / N)

Submission status: Wrong Answer

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

for i in range(N):
  E += 1 / N * (0.5 ** (N + 1 - i))
  
print(E)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N,K=map(int,input().split())
s=[]
t=0
for i in range(1,N+1):
  if i<K:
    while t<(math.log2(K)-math.log2(i)):
      t+=1
    else:
      t=t
      k=(1/N)*(1/2)**t
      s.append(k)
      break
  else:
    s.append(1/N)
print(sum(s))

Submission status: Wrong Answer

Solution code:
import math
N,K=map(int,input().split())
s=[]
t=0
for i in range(1,N+1):
  if i<K:
    while t<(math.log2(K)-math.log2(i)):
      t+=1
    else:
      t=t
      s.append((1/N)*(1/2)**t)
      break
  else:
    s.append(1/N)
print(sum(s))

Submission status: Wrong Answer

Solution code:
import math
N,K=map(int,input().split())
s=[]
t=0
for i in range(1,N+1):
  if i<K:
    while t<(math.log2(K)-math.log2(i)):
      t+=1
    else:
      s.append((1/N)*(1/2)**t)
      break
  else:
    s.append(1/N)
print(sum(s))

Submission status: Wrong Answer

Solution code:
import math
N,K=map(int,input().split())
s=[]
t=1
for i in range(1,N+1):
  if i<K:
    while t<math.log2(K)-math.log2(i):
      t+=1
    else:
      s.append((1/N)*(1/2)**t)
      break
  else:
    s.append(1/N)
print(sum(s))

Submission status: Wrong Answer

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

for i in range(n):
    if i+1>=k:
        ans += 1/n
    else:
        ans += (1/n)*(0.5**(int((k/(i+1))**0.5)+1))

print(ans)

Submission status: Wrong Answer

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

p = 0
p += max(0,n - k / n)

p += sum([ 1 / n * (1 / 2 ** math.ceil(math.log2(k/x))) for x in range(1,n - max(0,n - k)+1)])

print(p)

Submission status: Wrong Answer

Solution code:
import sys 
readline = sys.stdin.buffer.readline
N,K = map(int, readline().split())
l = [2**i for i in range(15)]
ans = 0
for i in range(1,N+1):
  for j in l:
    if i*j < K:
      continue
    else:
      ans += 1/(N*j) 
      break
print(ans)

Submission status: Wrong Answer

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

# 普通に書いてよい。。？
probability = 0.0

for i in range(1,N+1) :
    toss_count = 0
    point = i
    while(K >= point) :
        toss_count += 1
        point = point * 2
    
    probability += 1 / (N * pow(2,toss_count))

print(probability)

Submission status: Wrong Answer

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

for i in range(1, N + 1):
    coin = 1
    if i <= K -1:
        while True:
            if K < 2**coin * i:
                score += (1/N) * (1/2)**coin
                break
            else:
                coin += 1
    else:
        count += 1
p = score + count/N

print(p)

Submission status: Wrong Answer

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

for i in range(1, N + 1):
    for coin in range(1, K):
        if K <= 2**coin * i:
            score += (1/N) * (1/2)**coin
            break
        else:
            pass
print(score)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split(" "))
print(N,K)
cnt=0
kaku=0

for i in range(1,N+1):
    total=i
    while(total < K):
        cnt+=1
        total*=2
    
    kaku+=1/N * (1/2)**cnt
    cnt=0

print(kaku)

Submission status: Wrong Answer

Solution code:
import math

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

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

    pro2 = 0
    for i in range(1,k):
        tmp_pro = 1 / n
        x = int(math.log(k/i, 2))
        if x!=int(x):
            x += 1
        y = (1/2)**x
        tmp_pro *= y
        pro2 += tmp_pro

    pro = pro1 + pro2

else:
    pro = 0

    for i in range(1,n+1):
        tmp_pro = 1 / n
        x = int(math.log(k/i, 2))
        if x!=int(x):
            x += 1
        y = (1/2)**x
        tmp_pro *= y
        pro += tmp_pro

print(pro)

Submission status: Wrong Answer

Solution code:
import math

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

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

    pro2 = 0
    for i in range(1,k):
        tmp_pro = 1 / n
        x = int(math.log(k/i, 2)) + 1
        y = (1/2)**x
        tmp_pro *= y
        pro2 += tmp_pro

    pro = pro1 + pro2

else:
    pro = 0

    for i in range(1,n+1):
        tmp_pro = 1 / n
        x = int(math.log(k/i, 2)) + 1
        y = (1/2)**x
        tmp_pro *= y
        pro += tmp_pro

print(pro)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
n, k = map(int, input().split())
t = 1/n
a = 0
for i in range(1, n+1):
    if i < k:
        s = (k + i-1) // i
        t2 = math.ceil(np.log2(s))
        print(i, t2)
        a += t*((1/2) ** t2)
    else: a += t
print(a)

Submission status: Wrong Answer

Solution code:
N,K = list(map(int,input().split()))
per = 0
def f(x,y):
    count = 0
    while (x <= y):
        x = 2*x
        count += 1
    return count

for i in range(N):
    b = int(f(i+1,K))
    per += (1/N)*((1/2)**b)
print(per)

Submission status: Wrong Answer

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

prob = 0
for i in range(1,N+1):

    for j in range(17):
        if i*2**j >= K:
#             print(i,K,j,2**j)
            prob += 1/2**j
            break

print(prob/N)

Submission status: Wrong Answer

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

    ans = 0

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

if __name__ == '__main__':
    main()