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
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),s))
    res = list(map(lambda a:(1/n)*math.pow(1/2,a),b))
    return sum(res)
n,k = map(int, input().split())
print(Coin(n,k))

Submission status: Wrong Answer

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

poss = 0
for i in range(1,N):
	point = i
	cou = (K-1)//(2*point)
	poss = poss + 0.5 * cou
print(poss)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

import math
from fractions import Fraction

n, k = [int(x) for x in input().rstrip().split(" ")]
proba = Fraction(1, n)
proba_coin_fractions = []  # type: list[Fraction]
for i in range(1, n + 1):
    if i == k:
        proba_coin_fractions.append(Fraction(1, 1))
        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(Fraction(1, int(2 ** min_power_over_k)))

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

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(math.log2(i/k))
print(p/n)

Submission status: Wrong Answer

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

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

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 = (ans + 1)/2
    else:
        loop = 0
        tmp = i
        while True:
            tmp *= 2
            loop += 1
            if tmp > K:
                break
        ans += 1/N * (1/2)**loop
print(ans)

Submission status: Wrong Answer

Solution code:
import math
import numpy as np

def findnext(l, mx):
    for i in range(1, mx+1):
        if i not in l:
            return i
    return -1

def solve():
    n, k = map(int, input().split())
    prob = np.float64(0.0)
    for i in range(1, n+1):
        #i:出目
        #L:必要なコイン投げ回数
        if k > i:
            L = math.ceil(math.log2(float(k)/float(i)))
            prob += np.power(np.float64(0.5), L)
            print(prob)
        else:
            prob += np.float64(1.0)

    prob = prob / np.float64(n)
    print(prob.astype(str))

solve()

Submission status: Wrong Answer

Solution code:
N,K =map(int,input().split())
n = 0
ans = 0
L = K-1
R = N
while True:
    if L < N:
        break
    else:
        n += 1
        R = L
        L = R//2

if R > N:
    R=N

while True:
    foo = R-L
    foo /= 2**n
    ans += foo
    if L==2:
        ans += 3/(2**(n+2))
        break
    R = L
    L =R//2 +1
    n += 1
print(ans/N)

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:
n,k=map(int,input().split())
lst=[]
a=1
for m in range(1,n+1):
  for i in range(100000):
    if m*a>=k:
      lst.append(a)
      break
    else:
      a*=2
totl=0
for j in range(n):
  totl+=0.5**lst[j]
print(totl/n)

Submission status: Wrong Answer

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

r = 0

for i in range(1, n+1):
  if i >= k:
    r += 1/n
  else:
    hoge = 1
    while True:
      hoge += 1
      comp = 2**hoge
      if comp >= k/i:
        r += 1/(comp * n)
        break

print(r)

Submission status: Wrong Answer

Solution code:
import math

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

# for i in range(1, min(K, N + 1)):
#     print(math.ceil(math.log2(K / i)))
#     p += 2 ** (-math.ceil(math.log2(K / i)))
#
# p += max(0, N - K + 1)
# print(p / N)
count = 1
while True:
    p += max(0, min(N + 1, math.ceil(K / 2 ** (count - 1))) - math.ceil(K / 2 ** count)) * 0.5 ** count
    print(p)
    count += 1
    if K / 2 ** count < 0.5:
        break

p += max(0, N - K + 1)
print(p / N)

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*N)
        else:    
            S+=(1/N)*((1/2)**(int(math.log2(K/i)+1)))
else:
    for i in range(1,N+1):
        S+=(1/N)*((1/2)**(int(math.log2(K/i)+1)))
print(S)

Submission status: Wrong Answer

Solution code:
from decimal import *
getcontext().prec = 28
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))
print(answer)

Submission status: Wrong Answer

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

def twice(now, cnt):
    #print(now)
    if now >= 10:
        return cnt
    cnt += 1
    return twice(now * 2, cnt)

if __name__ == '__main__':
    ans = 0
    for i in range(1, n+1):
        cnt = 0
        #print(twice(i, cnt))
        #print((1/2)**int(twice(i)))
        ans += float(1/n) * float((1/2)**int(twice(i, cnt)))
    print(ans)

Submission status: Wrong Answer

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

ans = 0

for i in range(1,n+1):
    #print(i)
    if i == k:
        ans += n-k+1
        break
    for j in range(1,100000):
        if i * (2**j) > k:
            ans += (1/2)**j
            #print(ans)
            break

ans = ans * 1.0/n

print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

import sys
import math
input = sys.stdin.readline

# N = int(input())
# L = [int(x) for x in input().split()]
N, K = map(int, input().split())
# S = input()

max_pow = int(math.log2(K) + 0.9)

one_half = [0] * (max_pow + 1)
one_half[0] = 1
for i in range(1, max_pow + 1) :
    one_half[i] = one_half[i - 1] * 0.5

ans = 0
for i in range(1, N + 1) :
    pow_num = int(math.log2(K / i) + 0.9)

    if pow_num <= 0 :
        ans += 1
    else :
        ans += one_half[int(math.log2(K / i) + 0.9)]

print(ans / N)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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+=1/N
    else:
        cnt = math.ceil(math.log2((k)/i))
        print(cnt)
        p += (1/N)*(1/2)**cnt
    
print(p)

Submission status: Wrong Answer

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

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

p = p / n
print(p)

Submission status: Wrong Answer

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

for i in range(1,n+1):
    if i < k:
        ee=math.ceil((math.log(k)-math.log(i))/math.log(2))
        ans+=(1/2)**ee/n
    else:
        ans+=1.0/n
print(ans)

Submission status: Wrong Answer

Solution code:
def cc(n):
    i = 0
    while True:
        if K <= (n * i ** 2):
            return i
        i += 1


N, K = map(int, input().split())
A = 0
for n in range(1, N+1):
    A += 1.0 / N * (0.5 ** cc(n))
print(A)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
lst=[]
a=1
for m in range(1,n+1):
  for i in range(100000):
    if m*a>=k:
      lst.append(a)
      break
    else:
      a*=2
totl=0
for j in range(n):
  totl+=0.5**lst[j]
print(totl)

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 = preans * float(Decimal(1) / Decimal(n))
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N, K= map(int, input().split())
li = []
le = []
for i in range(N):
    A = math.log2(K/(i+1))
    kaisu = math.ceil(A)
    le.append(kaisu)
    li.append((0.5**kaisu)/N)
sumli = sum(li)
print(sumli)

Submission status: Wrong Answer

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

def count(i,K):
    sum = 0
    cnt = 0
    while sum < K:
        if cnt == 0:
            sum = i*2
            cnt += 1
        else:
            sum = sum*2
            cnt += 1
    return cnt

if N > K:
    prob = (N-K+1)/N
else:
    prob = 0


for i in range(1,N+1):
    if i <= K-1:
        prob += (1/N)*((1/2)**count(i,K))
    else:
        break

print(prob)

Submission status: Wrong Answer

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

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

	ans = 0
	tmp = 1/n

	for i in range(1, n+1):
		if i > k:
			ans += tmp
			continue
		count = 0
		num = i
		while True:
			num *= 2
			count += 1
			if num > k:
				ans += tmp * pow(0.5, count)
				break

	print(ans)



if __name__ == '__main__':
	import sys
	sys.exit(main())

Submission status: Wrong Answer

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

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

a = k
for i in range(1, 17):
    b = -(-a // 2)
    if b <= n:
        ans += min(a - b, n + 1 - b) / n * (0.5) ** i
    a = b
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
n,k=map(int,input().split(" "))
ans1=0
for i in range(1,n+1):
    c=0
    while(i<=k):
        i*=2
        c+=1
    ans1+=0.5**c
   # print(c)
print(ans1*(1/n))

Submission status: Wrong Answer

Solution code:
import numpy as np
n,k=map(int,input().split())
s=np.arange(n)+1
s=k/s
s=np.ceil(np.log2(s))
s=np.power(0.5,s)
s=np.sum(s)/n
print(s)

Submission status: Wrong Answer

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

n, k = map(int, input().split())
prob = []
for i in range(1, n+1):
  total = i
  count = 0
  while total <= k:
    total *= 2
    count += 1
  prob.append(1/n * 0.5**count)

print(sum(prob))

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int,input().split())
#N, K = 3, 10

ans = 0
total = 0
for i in range(0,N):
	#dice_times = math.ceil(math.log2(K/(i+1)))
	dice_times = int(math.log2(K/(i+1))) + 1
	total = total + (0.5**dice_times)

ans = (1/N) * total
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
N , K = map(int,input().split())
prob = 1/N
ans = 0
num = int(math.log2(K) // 1 + 1)
K_ = K
if N >= K:
	i = 0
	while i < num+10:
		if isinstance(K_, int):
			temp_K = int(K_)
		else:
			temp_K = int((K_ // 1) + 1) 
		ans += prob * (N - temp_K + 1)
		i += 1
		prob = prob * (1/2)
		N = temp_K - 1
		K_ = K_ / 2
else:
	i = 0
	while i < num+10:
		if N < K_:
			K_ = K_ / 2
			prob = prob * (1/2)
			i += 1
		else:
			if isinstance(K_, int):
				temp_K = int(K_)
			else:
				temp_K = int((K_ // 1) + 1) 
			ans += prob * (N - temp_K + 1)
			i += 1
			prob = prob * (1/2)
			N = temp_K - 1
			K_ = K_ / 2
		
		


print(ans)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
g = 0
if N < K:
    #w = 1/(K-1)
    for i in range(1,N+1):
        t = i
        gk = 1
        while (t < K):
            gk /= 2
            t *= 2
        #print(i,gk,1/gk)
        g += gk
else:
    f = (N-K+1)
    for i in range(1,K+1):
        t = i
        gk = 1
        while (t < K):
            gk /= 2
            t *= 2
        #print(i,gk,1/gk)
        g += gk
    g += f
print(g/N)

Submission status: Wrong Answer

Solution code:
import math
N, K= map(int, input().split())
li = []
le = []
for i in range(N):
    A = math.log2(K/(i+1))
    kaisu = math.floor(A)+1
    le.append(kaisu)
    li.append((0.5**kaisu)/N)
sumli = sum(li)
print(sumli)

Submission status: Wrong Answer

Solution code:

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

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

Submission status: Wrong Answer

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

print(float(sum(list)))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math


def main():
    N, K = map(int, input().split())
    ans = 0
    for i in range(N): 
        tmp = K / (i+1)
        a = math.log2(tmp)
        if a < 0:
            a = 0
        elif not a.is_integer():
            a = int(a) + 1
        '''
        if tmp.is_integer():
            tmp = int(tmp)
            if not (tmp and ):
                a = int(math.log2(tmp))
        else:
            a = int(math.log2(tmp)) + 1
        '''
        print(a)
        ans += 0.5 ** a
    ans /= N

    print(ans)


main()

Submission status: Wrong Answer

Solution code:
import numpy as np

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

prob = 0
for n in range(1,N):
    if n >= K:
        prob += 1
        continue
    else:   
        x = max(1, np.log2(float(K)/n))
        prob += 0.5**np.ceil(x)

prob /= N

print(prob)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
answer = 0
for i in range(N):
  dice = i + 1
  time = 0
  while (True):
    dice = dice * 2
    time += 1
    if dice >= K :
      answer += (1/N)*((1/2)**time)
      break
print(answer)

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/n)
  else:
    flag=1
    kaisu=0
    while flag==1:
      kaisu+=1
      hoge=hoge*2
      if(k<hoge):
        flag=0    
    ans+=(1/n)*((1/2)**kaisu)
print(ans)

Submission status: Wrong Answer

Solution code:
N, k=map(int, input().split())
flag=0
if N>=k:
    NN=N-k+1
    M=k-1
    flag=1
else:
    M=N
lls=[]
l=1
while True:
    if 2**l >=k:
        break
    else:
        l+=1
lls.append(l)
if M>=2:
    for s in range(2,M+1):
        for i in range(l,-1,-1):
            if 2**i <k/s:
                lls.append(i+1)
                break
s=0
for i in range(len(lls)):
    s+=0.5**lls[i]
print(s/N if flag==0 else (s+NN)/N)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
sum = 0
for i in range(1, n + 1):
    p = 1 / n
    score = i
    count = 0
    pp = 1.0
    while score <= k:
        score = score * 2
        p *= 0.5
    sum += p
print(sum)

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
ans = 0.0
for i in range(1,N+1,1):
    count = 0
    tmp = i
    if tmp < K:
        while True:
            tmp *= 2
            count += 1
            if tmp>K:
                break
    ans += float(1/N)*(0.5**count)
print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
coin_num_list = []
for i in range(1, min(K, N+1)):
    dice_val = i
    j = 0
    while dice_val < K:
        dice_val *= 2
        j += 1
    coin_num_list.append(j)
pro_sum = 0
for coin_val in coin_num_list:
    pro_sum += (1/2)**coin_val
if N > K:
    print((N-K+1)/N + pro_sum/N)
else:
    print(pro_sum/N)

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd
from functools import reduce
from itertools import combinations

import numpy as np

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def pattern(k):
    a = [2]
    for i in range(1, k):
        a.append(2 ** i)
        if 2 ** i > k:
            break
    return a[::-1]


def solve():
    N, K = il()
    ans = 0 if N < K else N - K + 1
    for k in pattern(K)[:N]:
        ans += 1 / k
    return format(ans / N, ".20f")


if __name__ == "__main__":
    print(solve())

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,k = na()

dp = [0]*(k-2)+[1]+[0]
m = 1
while True:
    a = int((k-0.1)//(2**m))
    if a < 1:
        break
    dp[a-1] += 1
    m += 1

b = 0
for i in range(k)[::-1]:
    b += dp[i]
    dp[i] = b

ans = 0
for j in range(n):
    if j < k:
        ans += 1/(2**dp[j])
    else:
        ans += 1

print(ans/n)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
g = 0
if N < K:
    #w = 1/(K-1)
    for i in range(1,N+1):
        t = i
        gk = 1
        while (t < K):
            gk /= 2
            t *= 2
        #print(i,gk,1/gk)
        g += gk
else:
    f = (N-K+1)
    for i in range(1,N+1):
        t = i
        gk = 1
        while (t < K):
            gk /= 2
            t *= 2
        #print(i,gk,1/gk)
        g += gk
    g += f
print(g/N)

Submission status: Wrong Answer

Solution code:
def main():
    n, k = list(map(int, input().split()))
    expect = 0
    for x in range(1, n + 1):
        if x > k - 1:
            expect += 1 / n
            continue
        n2w = 1
        for j in range(1, 100000):
            if x * (2**j) > k:
                n2w = j
                break
        # print(f'n: {n} k: {k} x: {x} n2w: {n2w}')
        expect += (1 / n) * ((1 / 2) ** n2w)

    print(expect)


main()

Submission status: Wrong Answer

Solution code:
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 = bunsi / bunbo
print(answer)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
import math
ans = 0.0
for i in range(1,n+1):
    if i < k:
        x = int(math.log(k/i, 2)) + 1
        ans += (0.5)**x / n
    else:
        ans += 1/n
print('{:.10f}'.format(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math


def probability(init, K):
    if init >= K:
        return 1
    min_n = int(math.log(K/init, 2)) + 1
    p = 1 / (2 ** min_n)
    return p


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

p = 0
for init in range(1, N+1):
    p += 1/N * probability(init, K)

print(p)

Submission status: Wrong Answer

Solution code:
def main():
    n, k = list(map(int, input().split()))
    expect = 0
    for x in range(1, n + 1):
        if x > k - 1:
            expect += 1 / n
            continue
        n2w = 1
        for j in range(1, 100000):
            if x * (2**j) > k:
                n2w = j
                break
        # print(f'n: {n} k: {k} x: {x} n2w: {n2w}')
        expect += (1 / n) * ((1 / 2) ** n2w)

    print(expect)

Submission status: Wrong Answer

Solution code:
import bisect
import decimal

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

k2 = k
a = []

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

a.sort()
l = len(a)

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

print('{:.10f}'.format(decimal.Decimal(ans / n)))

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
g = 0
if N < K:
    #w = 1/(K-1)
    for i in range(1,N+1):
        t = i
        gk = 1
        while (t < K):
            gk /= 2
            t *= 2
        print(i,gk,1/gk)
        g += gk
else:
    f = (N-K+1)
    for i in range(1,N+1):
        t = i
        gk = 1
        while (t < K):
            gk /= 2
            t *= 2
        print(i,gk,1/gk)
        g += gk
    g += f
print(g/N)

Submission status: Wrong Answer

Solution code:
import sys
import math

def solve(n, k):
    ans = 0.
    rate = 1./n
    for i in xrange(n):
        if i + 1 >= k:
            ans += rate
        else:
            ans += rate * 0.5 ** (int(math.log(k/(i+1), 2)) + 1)

    return ans

if __name__ == '__main__':

    n, k = sys.stdin.readline().strip().split(" ")
    print solve(int(n), float(k))

Submission status: Wrong Answer

Solution code:
import math

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

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

sum = base

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

print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
p = 1 - (K-1)/N
for i in range(1, K):
  n = math.ceil(math.log(K/i, 2))
  p += 1/N * (1/2 ** n)
print(p)

Submission status: Wrong Answer

Solution code:
from fractions import Fraction
N,K = map(int, raw_input().split())
ans = float(0)
if N > K:
	ans += Fraction(N-K+1,N)
pre = min(N,K)
sisu = 1
while True:
	if(pre == 1):
		break
	now = K - (K * (2**sisu - 1))/ (2**sisu)
	if(pre > now):
		ans += (Fraction(pre-now, N * 2**sisu))
	sisu += 1
	pre = min(now,N+1)
print(ans)

Submission status: Wrong Answer

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

p = 0.0
M = N
if N >= K:
	p += (N-K+1)
	M = K-1

t = 1
for i in range(0,15):
	if M*t >= K:
		break
	t *= 2

q = 0.0
while(M > 0):
	L = -(-M // t)
	q += L/t
	M = M-L
	t *= 2
p += q
print(p/N)

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int,input().split())
#N, K = 3, 10

ans = 0
total = 0
for i in range(0,N):
	dice_times = math.ceil(math.log2(K/(i+1)))
	total = total + (0.5**dice_times)

ans = (1/N) * total
print(ans)

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+=(1/N)
    else:
        cnt = math.ceil(math.log2((k-1)/i))
        p += (1/N)*(1/2)**cnt
    
print(p)

Submission status: Wrong Answer

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

p = 0.
for i in range(1, min(n+1, k)):
    count = 0
    while(i < k):
        i *= 2
        count += 1
    p += (0.5)**count
p *= 1/n

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

Submission status: Wrong Answer

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

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

  p = p / n
  print(p)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(1,N+1):
  if i >= K:
    ans=ans+1.0/N
    continue;
    
  hi=20
  lo=1
  while hi-lo>1:
    mid=(hi+lo)//2
    if i*(2**mid)>=K:
      hi=mid
    else:
      lo=mid
    
  ans=ans+1.0/N*(0.5**hi)
  
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    n, k = list(map(int, input().split()))
    expect = 0
    for x in range(1, n + 1):
        n2w = 1
        for j in range(1, 100000):
            if x * (2**j) > k:
                n2w = j
                break
        # print(f'n: {n} k: {k} x: {x} n2w: {n2w}')
        expect += (1 / n) * ((1 / 2) ** n2w)

    print(expect)


main()

Submission status: Wrong Answer

Solution code:
import math

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

naru = 0

for i in range(1, N+1):
    if i >= K:
        naru += 1
    else:
        kaisuu = math.ceil(math.log2(K / i))
        naru += 0.5 ** kaisuu
        print(kaisuu)
    print(i, naru)

print("{:.12f}".format(naru / N))

Submission status: Wrong Answer

Solution code:
import sys
import math 
import numpy as np
ni = lambda: int(ns())
na = lambda: list(map(int, input().split()))
ns = lambda: input()
N,K=na()
n=N
k=10**9
cnt=0
if(N==1):
    if(K==1):
        print(1)
        exit()
    else:
        while(N<K):
            N*=2
            #print(N)
        print(0.5**N)
        exit()
while(N<K):
    #print(N,K)
    K=math.ceil(K/2)
    cnt+=1
k=K

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, k=map(int, input().split())
flag=0
if N>=k:
    NN=N-k+1
    M=k-1
    flag=1
else:
    M=N
lls=[]
l=1
while True:
    if 2**l >=k:
        break
    else:
        l+=1
if M>=2:
    lls.append(l)
    for s in range(2,M+1):
        for i in range(l,-1,-1):
            if 2**i <k/s:
                lls.append(i+1)
                break
s=0
for i in range(len(lls)):
    s+=0.5**lls[i]
print(s/N if flag==0 else (s+NN)/N)

Submission status: Wrong Answer

Solution code:
N,K = map(int, input().split())
cnt = 0
binary = [2**i for i in range(15) if 2**i < 10**5]
#print(binary)
for i in range(1,N+1):
    tmp = K / i
    for j in range(len(binary)):
        if tmp < binary[j]:
            break
    #print(j, tmp)
    cnt += 0.5**(j) / N
print(cnt)

Submission status: Wrong Answer

Solution code:
import math

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

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


print(total)