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

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

ans = 0
for i in range(1, n + 1):
    j = 17
    while i * 2 ** j >= k and j >= 0:
        j -= 1
    ans += 1 / n * (1 / 2) ** (j + 1)
print(ans)

Solution (Python):
n,k = map(int,input().split())
num = [i for i in range(1,n+1)]
count = []
for i in range(n):
    j = 0
    while num[i]*(2**j)<k:
        j += 1
    count.append((1/2)**j)
ans = sum(count)*(1/n)
print(ans)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
ans = 0
for i in range(1, N + 1):
    
    point = i
    tmp = 1 / N
    cnt = 0
    while point < K:
        tmp *= 1 / 2
        point *= 2
        cnt += 1
    
    ans += tmp
print(ans)

Solution (Python):
n,k = map(int,input().split())
point = 0

for i in range(1,n+1):
    j = 1/n
    if i >= k:
        point += j
        continue
    now = i
    count = 0
    while now < k:
        now *= 2
        count += 1
    j *= (1/2)**count
    point += j
    
print(point)

Solution (Python):
n, k = map(int, input().split())
li = [0]*18

def bisect(x):
    ok = 17
    ng = 0
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if x*(2**mid)>=k:
            ok = mid
        else:
            ng = mid
    return ok

for i in range(1, n+1):
    if i>=k:
        li[0] += n-i+1
        break
    li[bisect(i)] += 1

ans = 0
for i, j in enumerate(li):
    ans += 2**(-i)*j
print(ans/n)

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

ans=0
for i in range(1,n+1):
  if i>=k:
    ans+=1/n
    continue
  else:
    j=1
    while True:
      if 2**j>=(k/i):
        ans+=(1/n)*0.5**j
        break
      else:
        j+=1
print(ans)

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

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

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

Solution (Python):
n,k=map(int,input().split())
ans=0
for i in range(1,n+1):
  p=0
  c=0
  p+=i
  while 1<=p<k:
    p*=2
    c+=1
  ans+=(1/n)*(1/(2**c))
print(ans)

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

Solution (Python):
def main():
    N, K = (int(i) for i in input().split())
    bi = [2**i for i in range(21)]
    ans = 0
    for i in range(1, N+1):
        if K <= i:
            ans += 1/N
        else:
            for j, b in enumerate(bi):
                if K <= b*i:
                    ans += (1/N)*(1/2)**j
                    break
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    res = 0
    for i in range(1, n + 1):
        cnt = 0
        while i < k:
            i *= 2
            cnt += 1
        p = (1 / n) * pow(1 / 2, cnt)
        res += p
    print(res)


if __name__ == '__main__':
    resolve()

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

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

print(ans)

Solution (Python):
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
from math import pi, ceil, floor
import numpy as np
from collections import defaultdict, deque
from operator import itemgetter
from bisect import bisect_left, bisect_right, insort_left, insort_right
import sys
input = sys.stdin.readline





def main():
    n, k = map(int, input().split())
    ans = 0
    for i in range(1, n+1):
        score = i
        p = 1 / n
        while score < k:
            p *= 1 / 2
            score *= 2
        ans += p
    print(ans)

if __name__ == '__main__':
    main()

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

ans = 0
for i in range(1, N + 1):
    count = 0
    now = i
    while now < K:
        count += 1
        now *= 2
    
    ans += pow(0.5, count)
    

ans /= N

print (ans)

Solution (Python):
def main():
    n, k = map(int, input().split())
    answer = 0
    for i in range(1, n + 1):
        start = i
        coin_toss_time = 0
        while start < k:
            coin_toss_time += 1
            start *= 2
        answer += pow(2, -coin_toss_time) / n
    print(answer)


if __name__ == '__main__':
    main()

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

Solution (Python):
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) 
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    


MOD = 10**9 + 7
INF = 2**31  

from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  






N, K = read_ints()
mul = 1 / N
ans = 0
for i in ra(1, N + 1):
    n_coin = 0
    prob_win = 1
    while i < K:
        i *= 2
        prob_win /= 2
    ans += prob_win
print(ans * mul)

Solution (Python):

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

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

Solution (Python):
N,K=map(int,input().split())
sum=0
for i in range(1,N+1):
    coin=0
    while i < K:
        coin += 1
        i *= 2
    sum += (1/2)**coin
print(sum/N)

Solution (Python):
import math
N, K =map(int, input().split())
k = K
bordor = []
Ans = 0
while(K >= 1):
  bordor.append(K)
  K = K / 2
  
for i in range(len(bordor) - 1):
  if bordor[i] <= N:
    Ans += (math.ceil(bordor[i]) - math.ceil(bordor[i + 1])) * (1 / (2 ** (i + 1)))
    
 
  elif bordor[i] > N >= bordor[i + 1]:
    Ans += (N + 1 - math.ceil(bordor[i + 1])) * (1 / (2 ** (i + 1)))
    
if bordor[-1] != 1:
  Ans += 1 / (2 ** len(bordor))

if N >= k:
  Ans += (N - k + 1)
Ans = Ans / N  

print(Ans)

Solution (Python):
n,k=map(int,input().split());a=0
for i in range(1,n+1):
 j=1/n
 while i<k:i*=2;j/=2
 a+=j
print(a)

Solution (Python):
n,k=map(int,input().split())
ans=0
for i in range(1,n+1):
    count=0
    now=i
    if i<k:
        while now<k:
            now*=2
            count+=1
        ans+=0.5**count
    else:
        ans+=1



print(ans/n)

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

a = 0
for i in range(1, n+1):
    if i >= k:
        a += 1
        continue
    cnt = 0
    score = i
    while score <= k-1:
        score *= 2
        cnt += 1
    a += (1 / 2) ** cnt

ans = (1/n) * a
print(ans)

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

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


for i in range(min(n, k-1)):
    count = 0
    b = i+1
    while k > b:
        b *= 2
        count += 1
    
    a = 1/(n*pow(2, count))
    total += a

print(total)

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

Solution (Python):
import math

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

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

Solution (Python):


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

ans = 0
for i in range(1, n+1):
    if i >= k:
        ans += 1/n
    else:
        j = i
        c = 0
        while j<k:
            j <<= 1
            c += 1
        ans += (1/n)*pow(0.5, c)

print(ans)

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

Solution (Python):
N,K=map(int,input().split())
ans=0
B=[]
for i in range(N):
  k=i+1
  c=0
  while k<K:
    k*=2
    c+=1
  B.append(N*(2**c))
for i in range(len(B)):
  ans+=1/B[i]
print(ans)

Solution (Python):
N, K = map(int, input().split())
if N < K:
    prob = 0
    
    S = min(N+1, K)
    for i in range(1, S):
        counter = 0
        while True:
            counter += 1
            i *= 2
            if i >= K:
                break
        prob += 0.5 ** counter * (1/N)
    print(prob)
else:
    prob = (N-K+1)/N
    S = min(N+1, K)
    for i in range(1, S):
        counter = 0
        while True:
            counter += 1
            i *= 2
            if i >= K:
                break
        prob += 0.5 ** counter * (1/N)
    print(prob)

Solution (Python):
n, k = map(int, input().split())
ans = 0
for i in range(1,n+1):
    t = 1
    while i * t < k:
        t *= 2
    ans += 1 / t
print(ans / n)

Solution (Python):
N, K = map(int, input().split())
if N < K:
    prob = 0
    
    S = min(N+1, K)
    for i in range(1, S):
        counter = 0
        while True:
            counter += 1
            i *= 2
            if i >= K:
                break
        prob += 0.5 ** counter * (1/N)
    print(prob)
else:
    prob = (N-K+1)/N
    S = min(N+1, K)
    for i in range(1, S):
        counter = 0
        while True:
            counter += 1
            i *= 2
            if i >= K:
                break
        prob += 0.5 ** counter * (1/N)
    print(prob)

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

Solution (Python):
N,K=map(int,input().split())
b=0
for i in range(1,N+1):
    c=0
    while(i<K):
        i*=2
        c+=1
    b+=1/(N*2**c)
print(b)

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

ans = 0

for i in range(1,n+1):
    t = 1
    while i * t < k:
        t *= 2
    ans += 1 / t

print(ans / n)

Solution (Python):
n,k=map(int,input().split(' '))
i = 0
while pow(2,i) < k:
    i += 1 
q = 1;rate = 0;j = 0
while q <= n:
    while q*pow(2,(i-j)) >= k:
        j += 1
    j -= 1
    rate += min(1/pow(2,(i-j)),1)
    q += 1
print(rate/n)

Solution (Python):
def main():
  N, K = (int(x) for x in input().split())
  ret = 0
  for d in range(1, N + 1):
    cc = 0
    d = (K-1)//d
    while d > 0:
      d //= 2
      cc += 1
    ret += 1 / (N * pow(2, cc))
  print(ret)
  return

if __name__ == '__main__':
  main()

Solution (Python):
N, K = [int(i) for i in input().split(" ")]
P = []
ans = 0

def calc_num(n):
    num = 0
    while(n < K):
        num += 1
        n *= 2
    return num


for i in range(1,N+ 1):
    calc = calc_num(i)
    if calc:
        P.append(calc_num(i))
    else:
        P.append(-1)

for p in P:
    if p > 0:
        ans += (1/N) * ((1/2) ** p)
    else:
        ans += 1/N

print(ans)

Solution (Python):

import io

n, m = map(int, input().split())
counter = 0
for i in range(1, n + 1):
    j = 0
    while i * 2**j < m:
        j += 1
    counter += 1 / 2**j
print(counter / n)

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

ans = 0
for s in range(1, N+1):
    num = 0
    p = 1
    while s < K:
        s *= 2
        num += 1
        p /= 2
    ans += p

print(ans/N)

Solution (Python):
N,K = map(int, input().split())
w = 0
for i in range(1,N+1):
    c = 0
    while i < K:
        i = i * 2
        c += 1
    w += ((1/2)**c)

print(w*(1/N))

Solution (Python):
import sys
from math import log2, ceil

n, k = map(int, sys.stdin.readline().split())

def main():
    res = 0
    for i in range(1, n + 1):
        denom = 1
        while i < k:
            i *= 2
            denom *= 2
        res += 1 / denom
    res /= n
    print(res)   

if __name__ ==  '__main__':
    main()

Solution (Python):
n,k=map(int,input().split())
for i in range(99999):
  if 2**i<k:
    continue
  else:
    start=i
    break

key=start
def p(n):
  return 2**(n)

ans=1
for i in range(2,n+1):
  if i<k:
    if i*p(key-1)<k<i*p(key):
      pass
    elif i*p(key-1)==k:
      key-=1
    elif i*p(key-2)<k<i*p(key-1):
      key-=1
    ans+=p(start-key)
  else:
    ans+=p(start)
print('{:.11f}'.format(ans/(p(start)*n)))

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

ans=0
for i in range(1,n+1):
    cnt=0
    while i<k:
        i *=2
        cnt+=1
    ans+=(0.5**cnt)    

print(ans/n)

Solution (Python):
N, K = list(map(int, input().split()))
val = 1
num = 0
ans = 0

x = 1
while x < K:
    x = 2 * x

for i in range(N):
    target = N - i
    tmp = val
    while tmp * target < K:
        num += 1
        tmp = 2 * tmp
    val = tmp
    ans += x // tmp
print('{:.10g}'.format(ans / (N * x)))

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

total = 0
for i in range(1, n+1):
    score = i
    count = 0
    while score < k:
        score <<= 1
        count += 1
    total += 1 / (2 ** count)

print('{:.10g}'.format(total / n))

Solution (Python):










mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n,k = readInts()
    res = 0
    
    
    
    for n_ in range(1,n+1):
        tmp = 1.0
        n2 = n_
        while n2 < k:
            n2 *= 2
            tmp /= 2.0
        res += tmp
    print("%.010f"%(res/n))
if __name__ == '__main__':
  main()

Solution (Python):
import numpy as np
import math 
n,k = map(int,input().split())
ans = 0
for i in range(1,n+1):
    if i >= k:
        ans += 1/n
    else:
        num = math.ceil(np.log2(k/i))
        ans += (1/n)*(1/2)**num
    
print(ans)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, k = map(int, read().split())
ans = 0
for i in range(1, n + 1):
    cnt = 0
    check = i
    while k > check:
        check *= 2
        cnt += 1
    if cnt == 0:
        ans += 1 / n
    else:
        ans += 0.5 ** cnt * (1 / n)
print(ans)

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

ans = 0
for i in range(1,n+1):
  pb = 1/n
  if i>=k: ans += pb
  else:
    ans += pb*0.5**math.ceil(math.log2(k/i))
print(ans)

Solution (Python):
dice,goal=map(int,input().split())
ans=[]
for i in range(1,dice+1):
  Q=1/dice
  point=i
  cnt=0
  while point<goal:
    cnt+=1
    point*=2
  ans.append(Q*(0.5)**cnt)
print(sum(ans))

Solution (Python):
import math
n, k = map(int, input().split())
pro = 0
for i in range(1,n+1):
  x = i
  a = 0
  while x < k:
    a += 1
    x = x*2
  pro += (1/n) * 0.5**a
print(pro)

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



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

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

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

X=0
Ans=0
for i in range(N):
    if i+1<K:
        X=math.log2(K/(i+1))
        X2=math.ceil(X)
        Ans+=((0.5)**X2)*(1/N)
    else:
        Ans+=((N-K+1)/N)
        break


print(Ans)

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

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

print(ans)

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

if K <= N:
    pos = (N - K + 1) / N
else:
    pos = 0

if pos != 1:
    for i in range(1,K):
        if i == N+1:
            break
        point = i
        cnt = 0
        while point < K:
            point *= 2
            cnt += 1
        pos += (1/N) * (0.5 ** cnt)

print(pos)

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

res = 0

for i in range(N+1)[1:]:
  j = 0
  while i*(2**j) < K:
    j += 1
  res += (1/N) * ((1/2) ** j)

print(res)

Solution (Python):
import collections, math, bisect
from fractions import Fraction

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

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

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

if local:
    start=time.time()


N, K = ints()

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

ans*=oneprob

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

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

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

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

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

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

Solution (Python):
n, k = map(int, input().split())
ans = 0
a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072]
for i in range(1, n+1):
    res = k/i
    for j in range(len(a)):
        if res <= a[j]:
            res = j
            break
    ans += (1/n)*(0.5**res)
print(ans)

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

for i in range(1,N+1):
  count = i
  p = 1/N
  while count<K:
    count = count*2
    p = p/2

  ans = ans + p

print(ans)

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

p = 0
for i in range(1, N+1):
    cnt = 0
    x = i
    while True:
        x *= 2
        cnt += 1
        if x >= K:
            break
    if i <= K-1:
        p += (1/N)*(1/2)**(cnt)
    else:
        p += 1/N

print(p)

Solution (Python):
N,K=map(int,input().split())
sum=0


for i in range(1,N+1):
  target=i
  count=0
  while(target<K):
    target*=2
    count+=1
  sum+=(1/N)*(0.5**count)
print(sum)

Solution (Python):
import numpy as np
N,K = map(int,input().split())
P = np.zeros(N) + (1 / N)
A = np.arange(1,N+1)
while np.any(A < K):
    P[A < K] = P[A < K] / 2
    A[A < K] = A[A < K] * 2
print(np.sum(P))

Solution (Python):
n, k = map(int, input().split())
ans = 0
for i in range(1, n+1):
    cnt = 0
    while i * (2**cnt) < k:
        cnt += 1
    ans += (1/2)**cnt

print(ans/n)

Solution (Python):
n, k = map(int, input().split())
win = 0
for i in range(1, n+1):
    index = 0
    while pow(2, index) < k/i:
        index += 1
    win += pow(0.5, index)/n
print(win)

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

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

Solution (Python):
import sys
input=sys.stdin.readline
















N,K = map(int,input().split())
c = [0] * N
for i in range(1,N+1):
    j = i
    d = 0
    while j < K:
        j *= 2
        d += 1
    c[i-1] = d
s = 0
for k in c:
    s += (0.5) ** k
print(s/N)

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

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

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

print(ans)

Solution (Python):
import math


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

ans=0
for i in range(1,n+1):
    ans+=((1/2)**max(0,math.ceil(math.log2(k/i))))*1/n
    
print(ans)

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

def double(i,k):
    while i < k :
        i *= 2
    return i

for i in range(1,n+1):
    ans += (i / double(i,k)) / n
print(ans)

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

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

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

Solution (Python):
import math
n, k = [int(e) for e in input().split()]
sum = 0.0
for i in range(1, n+1):
  if i >= k:
    sum += 1.0
  else:
    sum += 0.5 ** math.ceil(math.log2(k/i))
print(sum / n)

Solution (Python):
import math

def calc(x,k,n):
    m = math.ceil(math.log2(k/x))
    y = 2**m
    if x >= k:
        return 1
    else:
        return 1/y
n,k = map(int,input().split())
ans = 0.0
for x in range(1,n+1):
    tmp = calc(x,k,n)
    ans += tmp
print(ans/n)

Solution (Python):
import numpy as np

N, K = map(int, input().split())
P = 0
for p in range(1, N+1):
  i = max(0, np.ceil(np.log2(K/p)))
  P += (1/N)*(0.5**i)
  
print(P)

Solution (Python):
import math

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

num_of_rolls = lambda dice, K: max(0, math.ceil(math.log2(K / dice)))
continius_probability = lambda rolls: (1 / 2) ** rolls
dice_probablility = lambda N: 1 / N

answer = sum([continius_probability(num_of_rolls(dice, K)) for dice in range(1, N + 1)])
answer *= dice_probablility(N)

print(answer)

Solution (Python):
import math

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

num_of_rolls = lambda dice, K: max(0, math.ceil(math.log2(K / dice)))
continius_probability = lambda rolls: (1 / 2) ** rolls
dice_probablility = lambda N: 1 / N

answer = 0
for dice in range(1, N + 1):
    answer += continius_probability(num_of_rolls(dice, K))
answer *= dice_probablility(N)

print(answer)

Solution (Python):
import math

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

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

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

print(answer)

Solution (Python):
N, K = map(int, input().split())
ans = 0
for i in range(1, N+1):
  tmp = i
  cnt = 0
  while(tmp < K):
    tmp = tmp * 2
    cnt += 1
  ans += 1 / (N * (2 ** cnt))
print(ans)

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

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

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

print(s)

Solution (Python):
n , k = map(int,input().split())
ans = 0
for i in range(1,n+1):
    for j in range(10000):
        if i*2**j >= k:
            ans += (1/n)*(0.5**j)
            break
print(ans)

Solution (Python):
import math
from fractions import Fraction

ans = 0
N, K = map(int, input().split())
for i in range(1,N+1):
	ans += Fraction(1,2**(math.ceil(math.log2(max(1,K/i)))))
ans = float(ans/N)
print(ans)

Solution (Python):
import math
from fractions import Fraction

ans = 0
N, K = map(int, input().split())
for i in range(1,N+1):
	ans += Fraction(1,2**(math.ceil(math.log2(max(1,K/i)))))
ans = float(ans/N)
print('{:.10f}'.format(ans))

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

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

print(ans)

Solution (Python):
from fractions import gcd
n, k = map(int, input().split())

"""
さいころの目がiとするとき、得点をk以上にするには
int(log(i))+x >= kを満たすxの回数。つまりk-log(i)回連続で表が出れば良い
"""
import math
ans = 0 

for i in range(1, n+1):
    ans += 1/n * 2**(-max(0, math.ceil(math.log2(k/i))))
print(ans)

Solution (Python):
import math
from decimal import Decimal

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

win = 0

for i in range(1, N+1):
    if K - i < 1:
        win += 1
        continue

    win += (1/2)**(math.ceil(math.log2(K/i)))
    

print('{:.10g}'.format(Decimal(win/N)))

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

ans = 0
for n in range(1, N+1):
    if n >= K:
        ans += 1
        continue
    ans += (1/2) ** math.ceil(math.log2(K / n))

print(ans / N)

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

Solution (Python):
N, K = map(int, input().split())
cnt = 0
for i in range(1, N+1):
    p = 0
    while i < K:
        i = i*2
        p += 1
    cnt += 1/2**p
print (cnt/N)

Solution (Python):

import sys
import numpy as np

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

N, K = lr()
dice = np.arange(1, N+1, dtype=np.int32)
need = np.zeros(N, np.int32)

for i in range(20):
    target = dice < K
    need[target] += 1
    dice[target] <<= 1 

rate = (.5) ** need
answer = rate.sum() / N
print(answer)

Solution (Python):

import sys
import numpy as np

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

N, K = lr()
dice = np.arange(1, N+1, dtype=np.int32)
need = np.zeros(N, np.int32)

for i in range(20):
    target = dice < K
    need[target] += 1
    dice[target] <<= 1 

counter = np.bincount(need, minlength=20)
power = np.full(20, .5, dtype=np.float64)
power[0] = 1
np.cumprod(power, out=power)

answer = (counter * power).sum() / N
print(answer)

Solution (Python):

import sys
import numpy as np

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

N, K = lr()
dice = np.arange(1, N+1, dtype=np.int32)
need = np.zeros(N, np.int32)

for i in range(20):
    target = dice < K
    need[target] += 1
    dice[target] <<= 1 

power = (.5) ** need
answer = power.sum() / N
print(answer)

Solution (Python):

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

Solution (Python):
N,K=map(int,input().split())
probability=0
for dice in range(1,N+1):
    coin=1/N
    point=dice
    while(point<K):
        point*=2
        coin/=2
    probability+=coin
print(probability)

Solution (Python):

import sys

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

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

answer /= N
print(answer)

Solution (Python):
N, K = map(int,input().split())
p = 1 / N
P = [p] * N
for i in range(min(N,K-1)):
    n = i + 1
    while n < K:
        P[i] *= (0.5)
        n = 2 * n
print(sum(P))

Solution (Python):
from math import log, ceil
N,K = map(int, input().split())
ans = [1/N * ((1/2)**ceil(log(K/(s+1))/log(2)) if s+1<K else 1) for s in range(N)]
print(sum(ans))

Solution (Python):
import math

n,m = map(int,input().split())
p = 0
for i in range(1,n+1):
  if i>=m:
    p += 1/n
  else:
    a = math.ceil(math.log2(m/i))
    p += (1/n)*((1/2)**a)
print(p)

Solution (Python):
n,k = map(int,input().split())
prob = 0
point = 0
for cube in range(1,n+1):
    if cube <= k-1:
        point = cube
        t = 0
        while True:
            point = point*2
            t += 1
            if point >= k:
                break
        prob += 1/n * ((1/2)**t)
    else:
        prob += 1/n
print(prob)

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

Solution (Python):
N,K=map(int,input().split())
def P(K):
	a=[K]
	b=K
	while b>1:
		b=(b+1)//2
		a.append(b)
	return  a
a=P(K)

for i in range(len(a)):
	if a[i]<=N:
		b=i
		break

ans=(N-a[b]+1)*((1/2)**b)
for j in range(b,len(a)-1):
	ans+=(a[j]-a[j+1])*((1/2)**(j+1))


print(ans/N)

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

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