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())
l=[]
for i in range(1,N+1):
  cnt=1
  sumk=i*cnt
  while sumk<K:
    cnt=2*cnt
  cntT=cnt/2
  p_i=(1/N)*(1/2)**cntT
  l.append(p_i)
print(sum(l))

Submission status: Wrong Answer

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

n=0
rest = 0
acc = 0
for i in range(1,N+1):
    if i==1:
        n = int(math.log(K)/math.log(i+1)+1)
    else:
        n = int(math.log(K)/math.log(i))

    rest = 1/N*(0.5**n)
    acc += rest

print(round(acc,12))

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0

for n in range(1,N+1):
    cnt = 0
    while True:
        if n * (2 ** cnt) >= K - 1:
            break
        else:
            cnt += 1
    ans += (1 / N) / (2**cnt)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math

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

res = 0.0

for i in range(1,n+1):
  if k <= i :
    res = res + 1
    continue
  for j in range(1,math.floor(math.log2(k))+2):
    if (i * (2 ** j)) > k :
      res += 0.5 ** j
      break
res = res / n
print(res)

Submission status: Wrong Answer

Solution code:
import math

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

rate = 0

temp = 1
cnt = 0

while True:
  if temp >= k:
    break
  else:
    temp *= 2
    cnt += 1

for i in range(1, n + 1):
  if i * (2 **cnt) > k > i * (2 ** (cnt - 1)):
    rate += 1 / n * 0.5 ** cnt
  else:
    cnt = max(0, cnt - 1)
    rate += 1 / n * 0.5 ** (cnt)

print(rate)

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:
n, k = map(int, input().split())

def fl(x):
    digits = 20
    form = '%.'+str(digits-1)+'e'
    return float((form % x))

results = []
for i in range(1, n+1):
    if i > k/2:
        results.extend([fl(1/2) for _ in range(i,k)])
        results.extend([fl(1) for _ in range(k,n+1)])
        break
    for j in range(1,k):
        if i * 2**j > k:
            break
    results.append(fl(1/2**j))
print(fl(sum(results)/n))

Submission status: Wrong Answer

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

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

for i in range(2, count+1):
    sum_prob += (1/n) * (1/2)**i
print(sum_prob)

Submission status: Wrong Answer

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

poss = 0
posssum = []
for i in range(1,N+1):
	point = i
	cou = 0
	while point <= K-1:
		point = 2*point
		cou=cou+1
	poss = 1.0/float(i) * 0.5 **(cou)
	posssum.append(poss)
#	print(poss)
print(sum(posssum))

Submission status: Wrong Answer

Solution code:
import math

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

    a = math.ceil(math.log2(k))
    total = 0


    if n < k: 
        for i in range(k//n):
            total += 0.5**a
            print(total)
            a -= 1
            if a <= 0:
                break
    else:
        for i in range(k+1):
            total += 0.5**a
            a = max(a-1, 1)
        total += n - k

    print(total/n)

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import Fraction

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

for i in range(1, N+1):
  flag = True
  score = i
  times = 0
  while flag:
    times += 1
    score *= 2
    if score >= K:
      flag = False
  ans += Fraction(1, N) * (Fraction(1, 2) ** times)

print(float(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

minNK = min(N, K-1)
sumA = 0

for i in range(1, minNK+1):
    c, k = 0, K
    while k >= i:
        k = int(k / 2)
        c += 1
    #print(i, c)
    sumA += (1.0 / float(N)) * math.pow(0.5, c)

if N > K:
    sumA += (1.0 / float(N)) * float(N - K + 1)
print(sumA)

Submission status: Wrong Answer

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

l_2 = []
x = 1
while 1:
    l_2.append(2 ** x)
    if 2 ** x > K:
        break
    x += 1

ans = 0
for i in range(N):
    if i + 1 >= K:
        ans += 1 / N
        continue
    for idx, val in enumerate(l_2):
        if (i + 1) * val > K:
            ans += 1 / N * 0.5 ** (idx + 1)
            break

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
a=[]#入力画面の二文字を別々の文字に格納
a=input().split(" ")
N=int(a[0])
K=int(a[1])

q=0
if K<=N:
    for i in range(1,K):
        p=(0.5)**((int(math.log2(K/i)))+1)
        q=p+q
    x=q/N
    y=(N-K+1)/N
    print(x+y)
elif N<K:
    for i in range(1,N+1):
        p=(0.5)**((int(math.log2(K/i)))+1)
        q=p+q
        print(p)
    print(q/N)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
x = 1
y = n
i_1 = 0
i_n = 0

while True:
    if x >= k:
        break
    x *= 2
    i_1 += 1
    
while True:
    if y >= k:
        break
    y *= 2
    i_n += 1

l = [1/n * (1/2)**i for i in range(i_n,i_1+1)]

print(sum(l))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 09:53:12 2019

@author: Owner
"""
import numpy as np
import sys
import collections
import scipy.misc
import math
from operator import itemgetter
import itertools
import copy
import bisect

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


"""
N, X = map(int, input().split())

x = list(map(int, input().split()))

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())

# 多次元配列の宣言（あとでintにすること。）（タプルにすること。）
dp = np.zeros((N+1, 4,4,4))
    
all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break
# 累積和
add = 1 # 問題によって決まる
res = 0
sums = [0]*(len(nums)+1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]
for i in range(0, len(nums), 2):
    left = i
    right = min(i+add, len(nums))
    tmp = sums[right] - sums[left]
    res = max(tmp, res)

#２分探索
li, ri = bisect.bisect_left(p_ac, l[i]-1), bisect.bisect_right(p_ac, r[i]-1)    

#ソート関数
org_list = [3, 1, 4, 5, 2]
new_list = sorted(org_list)
print(org_list)
print(new_list)
# [3, 1, 4, 5, 2]
# [1, 2, 3, 4, 5]

#Distance Transformation
    for h in range(0,H):
        for w in range(0,W):
            if h == 0 and w == 0:
                pass
            elif h == 0:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h-1][W-w]+1)
            elif w == 0:   
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1)
            else:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1, D[H-h-1][W-w]+1, D[H-h][W-w]+2)
            d_max = max(D[H-h-1][W-w-1], d_max)

"""
N, K = list(map(int, input().split()))
def main():
    p = 0.
    if K < N:
        p += float(N-K)/float(N)
    for n in range(1,min(K+1, N+1)):
        for i in range(1,2*K//N+1):
            if i >= math.log2(K/float(n)):
                p += 1./float(N)*(1/2.)**(i) 
                break
    
    print(p)
                
                
                
            
            
                

    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

import math
val = K
curr_max = N
result = 0

pow_count = 0
while curr_max >= 1:
    if curr_max >= val:
        ceil = curr_max-math.ceil(val)+1
        result += ceil/N * ((0.5) ** pow_count)
        curr_max = math.floor(val)
    val *= 0.5
    pow_count += 1

print result

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split(" "))
if N < K:
    n = (0.5**int(math.log(K/a, 2)+1) for a in range(1, N+1))
    p = sum(n)/N
    print(p)
else:
    p1 = (N-K+1)/N
    n = (0.5**int(math.log(K/a, 2)+1) for a in range(1, K+1))
    p2 = sum(n)/N
    print(p1+p2, p1, p2)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# abc126/abc126_c
import sys
from math import *

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))



def main():
    N, K = i2nn()
    if N >= K:
        s = N - K + 1
        n = K
    else:
        s = 0
        n = N + 1
    for d in range(1, n):
        s += 2**(-ceil(log2(K/d)))
        print(d, -ceil(log2(K/d)))
    print(s/N)

main()

Submission status: Wrong Answer

Solution code:
import math

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

sum = 0

for i in range(1, n+1):
    if i >= k:
        sum += 1 / n
    else:
        x = (math.log(k) - math.log(i)) / math.log(2)
        x = math.ceil(x)
        p = 1 / n * (1 / 2) ** x
        sum += p

print(sum)

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))
    else:
        ans = ans + 1

print(ans / n)

Submission status: Wrong Answer

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


count = 0

x = 0
for i in range(n, 0, -1):
    
    tmp = i
    if count == 0:
        while tmp <= k:
            tmp = tmp*2
            count += 1
    else:
        tmp = tmp * pow(2, count)
        while tmp <= k:
            tmp = tmp * 2
            count += 1    

    x += pow(0.5, count)
prob = (1/n) * x
print(prob)

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 = list(map(int, input().split()))

i = 0
L = N
res = 0
while K*2 > 1:
    if L > K:
        res += (int(L-K+1))/(2**i)
        L = int(K-0.1**9)
    i += 1
    K = K/2
print(res/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)
print(a/n)

Submission status: Wrong Answer

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

res = 0
for i in range(n):
    if i+1 < k:
        res += 1/n * (1/2)**(int(math.log2(k)-math.log2(i+1)+1))
    else:
        res += 1/n

print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

S=0

for i in range(1,N+1):
    S+=((1/2)**(int(math.log2(K/i))+1))
print(S/N)

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):
    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
    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:
n,k=map(int,input().split())
ans=0
for i in range(n):
  hoge=i+1
  if(k<=hoge):
    ans+=1
  else:
    flag=1
    kaisu=0
    while flag==1:
      kaisu+=1
      hoge=hoge*2
      if(k<hoge):
        flag=0    
    ans+=((1/2)**kaisu)
print(ans/n)

Submission status: Wrong Answer

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

def fl(x):
    digits = 10
    form = '%.'+str(digits-1)+'e'
    return float((form % x))

results = []
for i in range(1, n+1):
    if i > k/2:
        results.extend([fl(1/2) for _ in range(i,k)])
        results.extend([fl(1) for _ in range(k,n+1)])
        break
    for j in range(1,k):
        if i * 2**j > k:
            break
    results.append(fl(1/2**j))
print(fl(sum(results)/n))

Submission status: Wrong Answer

Solution code:
import math

n, k = input().split()
n = int(n)
k = int(k)
prob = 0
for i in range(1,min(k,n + 1)):
    pp = int(math.log2(k/i)) + 1    
    hea = 1/(2**pp)
    hea = hea * (1/n)
    prob = prob + hea
    #print(prob)
if (k <= n):
    prob = prob + (n- (k-1))*(1/n)
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:
        p2 = p*t/(2**(n-k))
        p=p/(2**(n-k))
        P+=p2
        k=n
        t = 1
    else:
        t +=1
P+=p/2*t
print (P/N)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import collections
import decimal

N, K = map(int,input().split())
coin = [0] * (K+1)
ans = 0

for i in range(K,0,-1):
    coin[i] += 1
    for j in range(1,20):
        if i % (2**j) == 0:
            coin[i//(2**j)] += 1

if N > K:
    ans += N-K+1

A = collections.Counter(coin[1:min(N+1,K)]).most_common()

for tmp in A:
    ans += (0.5)**tmp[0] * tmp[1]

print(decimal.Decimal(ans/N))

Submission status: Wrong Answer

Solution code:
import math
n,k=map(int,input().split())
p_lis = []
for x in range(1,n+1):
    if k>x:
        power = -((-math.log2(k//x))//1)
        p_lis.append(float(((1/2)**power)*(1/n)))
    else:
        p_lis.append(1/n)
print(sum(p_lis))

Submission status: Wrong Answer

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

print(cnt)

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)

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0

for n in range(1,N+1):
    cnt = 1
    while True:
        if n * (2 ** cnt) >= K:
            break
        else:
            cnt += 1
    ans += (1 / N) / (2**cnt)
print(ans)

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)))
  
  probablity = probablity + 1 / (a * 2 ** ceil)
  
print(probablity)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)
a = []
for i in range(1, n+1):
    for j in range(15):
        if i >= k:
            break
        i *= 2
    a.append(n * 2 ** j)
lcm = a[0]
for i in range(1, n):
    lcm = lcm * a[i] // gcd(lcm, a[i])
u = 0
for s in a:
    u += lcm // s
print(u/lcm)

Submission status: Wrong Answer

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

import math


p = 0

for i in range(n+1):
    if i>0:
        if i>=k:
            p += 1
        else:
            p += 2**(int(100+math.log2(i/k))-100)
print(p/n)
print(int(30-0.01))

Submission status: Wrong Answer

Solution code:
from math import ceil, log2
inp = lambda cast=int: list(map(cast, input().split()))
# printf = lambda s='', *args, **kwargs: print(str(s).format(*args), flush=True, **kwargs)
n, k = inp()
res = 0.0
for i in range(1, n + 1):
    m = int(log2(k / i) + 1)
    m = m if i < k else 0
    res += 1 / 2**m
print(res/n)

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 * 2 < K):
            T *= 2
            c += 1
        else:
            break
    S += 0.5 ** c

S /= 3
print(S)

Submission status: Wrong Answer

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

if N == K:
  s = base
  end = K
elif N > K:
  s = (N-K+1) / N
  end = K
else:
  s = 0
  end = N+1
for i in range(1, end):
  n = math.ceil(math.log2(K/i))
  print(i, n)
  s += base * (0.5 ** n)
print(s)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
u=0
p=0
m=1
while m<k:
  u=u+1
  m=m*2
ans=0
t=0
l=0
for i in range (1,n+1):
  if i>=k:
    t=t+1
  else:
    l=l+(0.5)**(u-p)
    if (i+1)*(2**(u-p))<=k:
      p=p
    else:
      p=p+1
print((l+t)/n)

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

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)):
    if N < K:
        dec_temp = math.pow(1.0/2,i+1)
        dec_temp = Decimal(str(dec_temp)) / Decimal(str(N))
        percentage_sum += power_list[i] * dec_temp
    else:
        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 = list(map(int, input().split()))

k = []
i = -1
while(all):
    i+=1
    p =K//(2**i)
    k.append(p)
    if p==0:
        break

k[0] -=1
k_ = np.array(k)
k_ = np.where(N<k_, N, k_)


k1 = []
per = 1
for i in range(len(k_)-1):
    per *=2
    k1.append(((k_[i]-k_[i+1])/per))

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

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

ans = float(0)

for i in range(N):
    a = float(0)
    if i>=K : a=1.0
    else : a = 1/(2**(math.floor(math.log2(K / (i + 1))) + 1))

    ans +=a

ans = ans/N
print(ans)

Submission status: Wrong Answer

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

ans = 0
if  N >= K:
    ans+= (N-K+1)/N
    max_N = K-1
else:
    max_N = N
a_=0
for x in range(max_N):
    a_+=pow(1/2,int(np.log2(K/(x+1)))+1)
#     print(ans)
ans += a_/N
print(ans)

Submission status: Wrong Answer

Solution code:
import math
def AAA(s,k):
    a = 1
    while s*math.pow(2,a) <= k:
        a = a+1
    return a
def Coin(n,k):
    s = [i+1 for i in range(n)]     
    b = list(map(lambda a:AAA(a,k) if a<k else 0,s))
    res = list(map(lambda a:(1/n)*math.pow(1/2,a) if a!=0 else 1/n,b))
    return sum(res)
n,k = map(int, input().split())
print(Coin(n,k))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
u=0
p=0
m=1
while m<k:
  u=u+1
  m=m*2
ans=0
t=0
l=0
for i in range (1,n+1):
  if i>=k:
    t=t+1
  else:
    l=l+(0.5)**(u-p)
    if (i+1)*(2**(u-p))<=k:
      p=p
    else:
      p=p+1
print(t)
print((l+t)/n)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

import math

n, k = [int(x) for x in input().rstrip().split(" ")]
proba = 1 / n
proba_coin_fractions = []
for i in range(1, n + 1):
    if i >= k:
        proba_coin_fractions.append(1.0)
        continue
    min_power_over_k = int(1 + math.log(k / i, 2))
    if min_power_over_k < 1:
        min_power_over_k = 0
    proba_coin_fractions.append(1.0 / int(2 ** min_power_over_k))

proba *= sum(proba_coin_fractions)
print(float(proba))

Submission status: Wrong Answer

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

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 * 2 < K):
            T *= 2
            c += 1
        else:
            print(c)
            break
    S += 0.5 ** c

S /= 3
print(S)

Submission status: Wrong Answer

Solution code:
import math
N,K=map(int,input().split())
p=[0 for i in range(20)]
for i in range(20):
  M=K
  for j in range(i):
    M=M/2
  p[i]=math.ceil(M)
t=N+1
i=0
A=0
ans=0
print(p)
while p[i]>N:
  i+=1
while p[i]!=1:
  s=p[i]
  ans+=((t-s)/2**i)/N
  t=s
  print(t,s,i,N)
  i+=1
s=p[i]
ans+=((t-s)/2**i)/N
print(t,s,i,N)
print(ans)

Submission status: Wrong Answer

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

for i in range(1,n+1):
    count = 0
    while True:
        if i*2**count < k:
            count += 1
            print(i,count)
        else:
            score.append(count)
            break

for s in score:
    res += (1/n)*((1/2)**s)

print(res)

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 float(Decimal(1) /Decimal(2**cs)) >= float(Decimal(n - i) / Decimal(k)):
            cs = cs + 1
        preans = preans + float(Decimal(1) / Decimal(2**cs))
    else:
        preans = preans + 1

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

Submission status: Wrong Answer

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

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

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

prob = prob / Decimal(n)
print(prob)

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
    else:
        x = math.ceil(math.log2(k))
        for i in range(2, x + 1):
            # print(i)
            probability += pow(1 / 2, i) / n
    print(probability)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
from fractions import Fraction

NK = [int(i) for i in input().split()]
answer = [0.0] * NK[0]

for i in range(NK[0]):
    value = int(math.log2(NK[1]) - math.log2(i+1)) + 1
    if(value < 0):
        value = 0
    answer[i] = Fraction(1, (NK[0] * (2**value)))
print(float(sum(answer)))

Submission status: Wrong Answer

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


def tell_power_number(number):
    i = 0
    while number * (2 ** i) <= K:
        i += 1
    return i


ans = 0
for k in range(1, N + 1):
    ans += 1 / N * (1 / 2) ** tell_power_number(k)


print(ans)

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
    y=k//i
    if y!=0:
        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 fractions import Fraction
li = input().split()
n = int(li[0])
k = int(li[1])

# n面サイコロ kは得点

# 1/nの確率で1~nが出る
# 勝つためにx回表を出し続ければ良い
# 目 * 2^x >= kとなればよい

answer = 0
for i in range(n):
    dicenum = i + 1
    winline = dicenum
    x = 0
    while winline < k:
        x += 1
        winline = dicenum * (2**x)
    if dicenum == 1:
        first_x = x
        bunbo = n * 2**x
        bunsi = 1
    elif x == 0:
        bunsi += 2**first_x
    else:
        bunsi += (first_x - x) * 2

# answer = Decimal(str(bunsi)) / Decimal(str(bunbo))
answer = float(Fraction(bunsi, bunbo))
print("{:.12f}".format(answer))

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]
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 min(N,K-1) == K-1:
    P += 1./float(N)*float(N-K+1)
print(P)

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0
for i in range(N):
    n = math.log2(k) - math.log2(i+1)
    if n < 0:
        n = 0
    if n > 0:
        n = int(n+1)
    ans = ans + 1/((2**n)*N)
print(ans)

Submission status: Wrong Answer

Solution code:
import math

n, k = input().split()
n = int(n)
k = int(k)
prob = 0
for i in range(1,k):
    pp = int(math.log2(k/i)) + 1    
    hea = 1/(2**pp)
    hea = hea * (1/n)
    prob = prob + hea
    print(prob)
prob = prob + (n- (k-1))*(1/n)
print(prob)

Submission status: Wrong Answer

Solution code:
import sys


def main():
    N, K = [int(x) for x in sys.stdin.readline().rstrip().split()]

    ans = 0
    for i in range(N):
        # print(f"1/{N} * (1 / 2) ** ({N+1-i})")
        ans += (1 / N) * (1 / 2) ** (N + 1 - i)

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

ka = 0

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

Submission status: Wrong Answer

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

l_2 = []
x = 1
while 1:
    l_2.append(2 ** x)
    if 2 ** x > K:
        break
    x += 1

ans = 0
for i in range(N):
    for idx, val in enumerate(l_2):
        if i + 1 >= K:
            ans += 1 / N
            break
        elif (i + 1) * val > K:
            ans += 1 / N * 0.5 ** (idx + 1)
            break

print(ans)

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

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)):
    if N <= K:
        dec_temp = math.pow(1.0/2,i+1)
        dec_temp = Decimal(str(dec_temp)) / Decimal(str(N))
        percentage_sum += power_list[i] * dec_temp
    else:
        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 math
N,K=map(int,input().split())

S=0

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