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 random
import functools

def add(a,b):
    return a+b
def stochast(n, k):
    point = n
    iteration = 0
    flag = point
    while flag<=k-1:
        flag *= 2
        iteration += 1

    return (1/point)*0.5**iteration    

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

ns = range(1, n+1)
stochasts = []

for i in ns:
    temp = stochast(i, k)
    stochasts.append(temp)

ans = functools.reduce(add, stochasts)

print(ans)

Submission status: Wrong Answer

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

list=[]

while 2**i<100000:
    list.append(2**i)
    i=i+1

#while x==0:
#    if k==1:
#        x=1
#        y=0
#    elif 2**i<k<=2**(i+1):
#        x=2**(i+1)
#        y=i+1
#    else:
#        i=i+1

sum=0.0
y=0
j=0

for i in range(1,n+1):
    if k%i!=0:
        x=(k//i)+1
    else:
        x=k//i
    for j in range(len(list)-1):
        if list[j]<x<=list[j+1]:
            y=j+1
    if k==1:
        y=0
#    print((1/n)*((0.5)**y))
    sum=sum+(1/n)*((0.5)**y)
    y,j=0,0

if sum>0.999999999999:
    print(1.0)
else:
    print(sum)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
ans = 0.0
for i in range(1, n + 1):
  hops = 0
  while i < k:
    hops += 1
    i *= 2
  ans += pow(1.0 / 2.0, hops + 1)
ans /= n
print('{:.10f}'.format(ans))

Submission status: Wrong Answer

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

# 初期のサイコロであがる確率
dice = 0
if K <= N:
    dice = (N - K + 1) / N

# コイン
dice_st = min(N, K - 1)

patt = N
coin = 0

for r in range(1, dice_st+1):
    ren = int(math.log(K, 2) - math.log(r, 2)) + 1
    coin += (1 / ((2**ren)*patt))

print(dice + coin)

Submission status: Wrong Answer

Solution code:
import math
nk = list(map(int, input().split()))

n = nk[0]
k = nk[1]

rate = 0
for i in range(1, n+1):
    if(i == 1):
        times1All = math.log(k, 2)
        times1 = times1All // 1
        rate += 1/n * 0.5 * (0.5 ** times1)

    else:
        timesAll = math.log(k, i)
        times = timesAll // 1
        rate += 1/n * (0.5 ** times)

print(rate)

Submission status: Wrong Answer

Solution code:
# C
import sys, math

n, k = map(int,input().split())
ans = 0
for i in range(30):
        if math.ceil(k * (1/(2**i))) == 1:
                break
        ans += k * (1/2**i) * max(n - math.ceil(k * (1/(2**i))), 0)

print(ans)

Submission status: Wrong Answer

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

p = 0
m = 0
ni = n
while True:
    if ni >= k/2**m:
        pi = (ni-math.floor(k/2**m))/n*(1/2)**m
        p += pi
        ni = math.floor(k/2**m)
        print(m, ni, p, pi)
    m += 1
    if ni == 0:
        break

print(p)

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 tmp & (tmp - 1) == 0:
                a = int(math.log2(tmp))
            else:
                a = int(math.log2(tmp)) + 1
        else:
            a = int(math.log2(tmp)) + 1
        if a < 0:
            a = 0
        ans += 0.5 ** a
    ans /= N

    print(ans)


main()

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:
        cnt = math.ceil(math.log(k - 1, 2) - math.log(i, 2))
    else:
        cnt = 0

    ans += (0.5 ** cnt) / n

print(ans)

Submission status: Wrong Answer

Solution code:
import math

n, k = map(int, input().split())
ans = 0
for i in range(n):
  x = int(math.log(k/(i+1), 2)+1)
  ans += (1/2)**x
  if i >= k:
    ans += 1/n
  # print(k/n, x, ans)
print(ans/n)

Submission status: Wrong Answer

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

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

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

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

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

Submission status: Wrong Answer

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

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

for i in range(1, n+1):
    if i >= k:
        array.append((float(1)/n)*(n-i+1))
        break
    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)*float(pow(1/2, time)))
    else:
        array.append(float(1)/n)



print(sum(array))

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = min([i for i in range(100) if 2**i > k])

b = [(1/n) * 0.5**(a-i) for i in range(a+1) if (a-i) > 1]
c = [1/n for i in range(n - len(b))]

print(sum(b) + sum(c))

Submission status: Wrong Answer

Solution code:
import math
import sys
from collections import Counter


def parse(file):
    n, k = map(int, file.readline().split())
    return n, k


def main(n, k):
    xs = []
    for i in range(n):
        d = i + 1
        if d >= k:
            xs += [0] * (n - d + 1)
            break
        x = math.ceil((math.log(k) - math.log(d)) / math.log(2))
        xs.append(x)

    c = Counter(xs)
    ans = 0
    for k, v in c.items():
        ans += ((1 / 2) ** int(k)) * v

    return ans / n


if __name__ == '__main__':
    print(main(*parse(sys.stdin)))

Submission status: Wrong Answer

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

ans = 0.
k = K
k_list = []
watta_count = 0
for _ in range(17):
  k = k/2
  if k <= 0.5:
    break
  elif k <= N:
    k_list.append(math.ceil(k))
  watta_count += 1
k_list.reverse()
if len(k_list) == 0:
    ans = 1
else:
    for i in range(len(k_list)-1):
        now = k_list[i]
        nex = k_list[i+1]
        cot = nex-now
        ans += (1/N)*((1/2)**watta_count) * cot
        watta_count -= 1
    aa = N-k_list[-1]+1
    ans += (1/N)*((1/2)**watta_count) * aa

print(ans)

Submission status: Wrong Answer

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

def win_num(f, k):
    i = 0
    F = f
    while F<k:
        F = f
        F = F*(2**i)
        i += 1
    if i == 0:
        return 0
    else:
        return i

ls = []
for f in range(n):
    wn = win_num(f+1, k)
    ls.append((1/n) + (1/2)**wn)
print(sum(ls))

Submission status: Wrong Answer

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

psum = 0
i = 1
while (i<=k):
    x = float(k/i)
    c = math.log2(x)
    p = float((1/n)*((1/2.0)**(math.ceil(c))))
    psum = float(psum)+p
    i= i+1
print(psum)

Submission status: Wrong Answer

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

l = 0
if N>=K:
  l = K - 1
else:
  l = N + 1

s = []
for a in range(1,l):
  b = 1
  for b in range(1,K//2):
    if a*(2**b) >= K:
      s.append((1/N)*(0.5**b))
      break
    
print(sum(s))

Submission status: Wrong Answer

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

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

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
import sys
from collections import Counter


def parse(file):
    n, k = map(int, file.readline().split())
    return n, k


def main(n, k):
    xs = []
    for i in range(n):
        d = i + 1
        if d >= k:
            xs += [0] * (n - d + 1)
            break
        x = math.ceil((math.log(k) - math.log(d)) / math.log(2))
        xs.append(x)

    print(xs)

    c = Counter(xs)
    ans = 0
    for k, v in c.items():
        ans += ((1 / 2) ** int(k)) * v

    return ans / n


if __name__ == '__main__':
    print(main(*parse(sys.stdin)))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
prob = 0
for i in range(N):
    if N / 10 < 10:
        break
    N //= 10
    print(N)

roll = K//N+1

for i in range(roll, 1, -1):
    prob += (1/N) * ((1/2)**i)

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

Submission status: Wrong Answer

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

a = 0
b = 0
l = []
for i in range(18):
    if (2 ** i >= k / n):
        a = i
        break
for i in range(b, 18):
    if (2 ** i >= k):
        b = i
        break

l.append([a, n + (-k) // (2 ** a) + 1])
for i in range(a + 1, b + 1):
    c = k // (2 ** (i - 1)) + (-k) // (2 ** i) + 1
    l.append([i, c])
print(l)
s = 0
for i in l:
    s += i[1] / (2 ** i[0])

print(s / n)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import math
a,b=input().split()
P=[]
for x in range(int(a)):
    v=math.log2(int(b)/(x+1))
    if int(v)<=0:
        y=0
    else:
        y=int(v)+1
    
        
    P.append(1/int(a)*pow(2,-y))



print(sum(P))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
W = []
i = 1
while K >= i :
  W.append(int((K//(i))-(K//(i*2))))
  i = i*2
dif = K - N
ans = 0
if dif <= 0:
  ans += -dif
else:
  j = 0
  while dif > 0:
    if W[j] >= dif:
      W[j] = W[j] - dif
      dif = 0
    else:
      dif = dif - W[j]
      W[j] = 0  
for h in range(len(W)):
  ans += W[h]/(2**(h+1))
ans = ans / N
print(ans)

Submission status: Wrong Answer

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

import math

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

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

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

    if k<1/2:
        break


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

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

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

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

Solution code:

from functools import reduce

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


def calc_p(n, c):
    return 1/n * pow(1/2, c)


def calc_dnm(n, c):
    return n * 2 ** c


def calc_lcm(ns):
    return reduce(lcm, ns, 1)


def lcm(x, y):
    return (x * y) // gcd(x, y)


def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x


for i in range(1, N+1):
    score = i
    cnt = 0
    while score <= K:
        score *= 2
        cnt += 1
    dnms.append(calc_dnm(N, cnt))
    p += calc_p(N, cnt)

l = calc_lcm(dnms)
mlcls = [l/x for x in dnms]
print(sum(mlcls) / calc_lcm(dnms))

Submission status: Wrong Answer

Solution code:
N,K=map(int, input().split())
ans=max(0.0,N+1-K)
r=K-1
p=1.0
i=1
import math
while r>0:
    l=min(r,math.ceil(K/(i*2)))
    p/=2
    if r<=N:
        ans+=p*(r+1-l)
    elif l<=N:
        ans+=p*(N+1-l)
    r=l-1
    i+=1
print(ans/N)

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  N,K=LI()
  a=1/N

  ans=0.0
  for i in range(1,N+1):
    c=1.0
    x=i
    while True:
      if x>K:
        break
      else:
        x*=2
        c*=2.0

    ans+=a/c+0.00000000005

  print(ans)

main()
# print(main())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
cnt_list = []
if N < K:
    for i in range(1, N + 1):
        cnt = 0
        while i < K:
            i *= 2
            cnt += 1
        cnt_list.append(cnt)
    print(1 - sum([(1 / N) * (1 - 0.5 ** i) for i in cnt_list]))
if N > K:
    for i in range(1, K):
        cnt = 0
        while i < K:
            i *= 2
            cnt += 1
        cnt_list.append(cnt)
    print(1 - sum([(1 / N) * (1 - 0.5 ** i) for i in cnt_list]))

Submission status: Wrong Answer

Solution code:
from fractions import Fraction

n, k = map(int, input().split())
count = [0] * n
ans = 0

for i in range(1, n+1):
    j = i
    num = k - i
    while num >= j:
        j *= 2
        count[i-1] += 1

all_pattern = [0] * n
for i in range(n):
    all_pattern[i] = Fraction(1, n*(2**count[i]))

all_pattern = sum(all_pattern)
frac_ans = Fraction(all_pattern)
ans = frac_ans.numerator / frac_ans.denominator

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

Submission status: Wrong Answer

Solution code:
n = list(map(int, input().split()))
a = []
for i in range(1, n[0]+1):
    a.append(i)
e = 0

for j in range(len(a)):
    c = a[j]
    d = 0
    while c <= n[1]:
        c *= 2
        d += 1
        if c >= n[1]:
            e += (1/a[-1] * 1/2**d)
print(e)

Submission status: Wrong Answer

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

i = 1
temp = 1
a = 0


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


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

Submission status: Wrong Answer

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

sum = 0.00000000000

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

print('{:.10f}'.format(sum))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
ans=0
con=0
m=n
l=k-1
INF=10**9

for i in range(INF):
    if m>l:
        p=(m-l)/n*((1/2)**i)
        m=l
        ans+=p
    if l==0:
        break
    if l%2==0:
        l=k//(2**(i+1))
    else:
        l=k//(2**(i+1))
    
        
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0

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

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

print(ans)

Submission status: Wrong Answer

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

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

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

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

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

Submission status: Wrong Answer

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

P = 0
for i in range(1,N):
  if i>= K:
    P += 1/N
  else:
    S = K - i
    j = 1
    P2 = 1
    
    while i*(2**j) >= S:
      P2 *= 1/2      
    P += (1/N)*P2

print(P)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = list(map(int, input().split()))
a = []
for i in range(1, n[0]+1):
    a.append(i)
e = 0

for j in range(len(a)):
    c = a[j]
    d = 0
    while c <= n[1]:
        c *= 2
        d += 1
        if c >= n[1]:
            e += 1/a[-1] * 1/2**d
print(e)

Submission status: Wrong Answer

Solution code:
import math

N, K = [int(i) for i in input().split()]
res = [2**(-math.ceil(math.log2(K/n))) for n in range(1, N+1)]
print(res)
print(sum(res)/N)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math
from decimal import Decimal
input = sys.stdin.readline

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

power_list =[] 
K_flag = N
K_temp = K

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

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

percentage_sum = Decimal("0.0")

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

print(percentage_sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

print(sum([pow(0.5, math.ceil(math.log2(K/a))) for a in range(1, N+1)])/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(200)]
#print(two)
k_tikai = 0
for j in range(len(two)):
    if k > two[j]: k_tikai = j
k_tikai += 1
tasu = 0.0

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

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


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

print(sum(array))

#print(tasu)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
cnt_list = []
if N < K:
    for i in range(1, N + 1):
        cnt = 0
        while i < K:
            i *= 2
            cnt += 1
        cnt_list.append(cnt)
    print(cnt_list)
    print(1 - sum([(1 / N) * (1 - 0.5 ** i) for i in cnt_list]))
if N > K:
    for i in range(1, K):
        cnt = 0
        while i < K:
            i *= 2
            cnt += 1
        cnt_list.append(cnt)
    print(cnt_list)
    print(1 - sum([(1 / N) * (1 - 0.5 ** i) for i in cnt_list]))

Submission status: Wrong Answer

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

if n >= k:
    a = (n-k+1)/n
    q = k-1
    e = 1
    while(q > 1):
        b += (math.ceil(q) - math.ceil(q/2)) / 2**e / n
        q /= 2
        e += 1
    if q <= 1:
        b += 1 / 2**e / n
    print("{:.12g}".format(a+b))
else:
    q = n
    e = 1
    while(True):
        if n**e >= k:
            e -= 1
            break
        else:
            e += 1

    while(q > 1):
        b += (math.ceil(q) - math.ceil(q/2)) / 2**e / n
        q /= 2
        e += 1
    if q <= 1:
        b += 1 / 2**e / n
    print("{:.12g}".format(b))

Submission status: Wrong Answer

Solution code:
n = list(map(int, input().split()))
a = []
for i in range(1, n[0]+1):
    a.append(i)
print(a)
e = 0

for j in range(len(a)):
    c = a[j]
    d = 0
    while c <= n[1]:
        c *= 2
        d += 1
        if c >= n[1]:
            e += 1/a[-1] * 1/2**d

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = min([i for i in range(100) if 2**i > k])

b = [(1/n) * 0.5**(a-i) for i in range(a+1) if (a-i) > 1]
c = (1 / n) * (n - len(b))

print(sum(b) + c)

Submission status: Wrong Answer

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

list=[]

while 2**i<100000:
    list.append(2**i)
    i=i+1

#while x==0:
#    if k==1:
#        x=1
#        y=0
#    elif 2**i<k<=2**(i+1):
#        x=2**(i+1)
#        y=i+1
#    else:
#        i=i+1

sum=0.0
y=0
j=0

for i in range(1,n+1):
    if k%i!=0:
        x=(k//i)+1
    else:
        x=k//i
    for j in range(len(list)-1):
        if list[j]<x<=list[j+1]:
            y=j+1
#    print((1/n)*((0.5)**y))
    sum=sum+(1/n)*((0.5)**y)
    y,j=0,0

print(sum)

Submission status: Wrong Answer

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

sum = 0

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

print('{:.9f}'.format(sum))

Submission status: Wrong Answer

Solution code:
def C():
    N, K = input().split()
    N = int(N)
    K = int(K)
    n = [i for i in range(1, N+1)]
    x2 = [2**i for i in range(15)]
    k = [K /n[i-1] for i in range(1, N+1)]
    #print(k)
    #print(x2)
    #print(len(n))
    #print(n[0])
    #print(len(k))
    c = []
    for x in n:
        for i in x2:
            if k[x-1] < i:
                #print('k:{}'.format(k[x-1]))
                #print('i:{}'.format(i))
                c.append(x2.index(i))
                break
    cc = [pow(0.5, i) for i in c]
    print(1 / N * sum(cc))
            
if __name__ == '__main__':
    C()

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

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

prob = 0

for i in range(1, N+1):
    x = math.ceil(np.log2(K/i))
    prob += (1/N) * (1/2)**x

print(prob)

Submission status: Wrong Answer

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

ls = []

def multiply(ls):
    result = []
    for i in range(len(ls)):
        result.append(pow(N, -1) * ls[i])
    return result

def sq(n):
    return pow(n, -cnt)

if N < K:
    for i in range(1, N + 1):
        p = i
        cnt = 0
        while p < K:
            p *= 2
            cnt += 1
        ls.append(pow(2, -cnt))
    print(sum(multiply(ls)))
else:
    for i in range(1, K):
        p = i
        cnt = 0
        while p < K:
            p *= 2
            cnt += 1
        ls.append(pow(2, -cnt))
    print(sum(multiply(ls)))

Submission status: Wrong Answer

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

jou = 0

while 2**jou < K:
    jou += 1

n_j = jou
node = 1.0
ans = 0.0

for i in range(N):
    ans += (1.0/N) * 0.5**n_j
    if (i+2)*2**(n_j - 1):
        n_j -= 1
    if n_j < 0:
        n_j = 0
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.log2(b / (i + 1)))
  if(ceil < 0):
    ceil = 0
    
  probablity = probablity + 1 / (a * 2 ** ceil)
  
print(probablity)

Submission status: Wrong Answer

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

mod = n
qtdMin = 1/n
mid = 1
while(mod<k):
    mod<<=1
    qtdMin*=0.5
    mid+=1
res = 0

for i in range(k,n):
    res += (1/n)
    
mod = qtdMin
res+=mod

for i in range(min(n,k)-1,0,-1):
    if(i*mid < k):
        mod*=0.5
        mid+=1
    res+= mod
print(abs(res))

Submission status: Wrong Answer

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

p = list()
for i in range(n):
    num = 1
    while 2 ** num * (i+1) <= k:
        num += 1
    p.append(1/(2 ** num * n))
print(sum(p))

Submission status: Wrong Answer

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

score = 0.0

for i in range(1, N+1):
  count = 0
  result = i
  while(result>K):
    result = i*2
    count+=1
  score += (1/N) * ((1/2)**count)

print(score)

Submission status: Wrong Answer

Solution code:
import numpy as np
from decimal import Decimal

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


prob = []
if N >= K:
    p_e = (1 / N) * (N - K + 1)
    for i in range(1, K):
        p_i = (1 / N) * ((1 / 2) ** (int(np.log2(K / i)) + 1))
        prob.append(p_i)
else:
    p_e = 0
    for i in range(1, N+1):
        p_i = (1 / N) * ((1 / 2) ** (int(np.log2(K / i)) + 1))
        prob.append(p_i)


print(sum(prob) + p_e)

Submission status: Wrong Answer

Solution code:
import math
N,K = map(int, input().split())
#出た目をｎとすると、n>=K以上が最初に出れば勝ち
#1からK-1のときで負ける確率を考える
ans=0
for i in range(1,K):
  j = math.log(K/i,2)
  for j in range(17):
    if j>=1:
      ans+=1-(1/2)**j

win_rate = 1-ans
print(win_rate)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  N,K=LI()
  a=1/N

  ans=0
  for i in range(1,N+1):
    c=1
    x=i
    while True:
      if x>K:
        break
      else:
        x*=2
        c*=2

    ans+=a*1/c

  print(ans)

main()
# print(main())

Submission status: Wrong Answer

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

i = 1
temp = 1
a = 0


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


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

Submission status: Wrong Answer

Solution code:
import numpy as np
from decimal import Decimal

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(Decimal(sum/n))
print('%.9f' % (sum/n))
#print("{:.9g}".format(sum/n))

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

N, K = list(map(int, input().split()))
A = []

for i in range(1, N+1):
    n = (1 - math.log(i, 10) + math.log(2, 10)) // math.log(2, 10)
    A.append(n)
    
score = 0
for i in range(N):
    score += (1 / N) * (1 / 2) ** A[i]

print(score)

Submission status: Wrong Answer

Solution code:
import math

n, k = map(int, input().split())
ans = 0
for i in range(n):
  x = int(math.log(k/(i+1), 2)+1)
  ans += (1/2)**x
  # print(k/n, x, ans)
print(ans/n)