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):
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():
    N, K = map(int, input().split())

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

    ans = ans / N
    print(ans)


if __name__ == '__main__':
    solve()

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

B = [[] for _ in range(N)]
for i, a in enumerate(range(1, N+1)):
    B[i] = max(math.ceil(math.log2(K/a)), 0)


ans = 0
for b in B:
    ans += 1/2**b
print(ans/N)

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

ans = 0
for i in range(n):
    tmp = 1 / n
    score = i + 1
    while score < k:
        score *= 2
        tmp /= 2
    ans += tmp

print(ans)

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

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

Solution (Python):
def getCount(a, b):
	count = 0
	while(True):
		if a < b:
			a = a*2
			count += 1
		else:
			return count

  
def answer(n, k):
    posibility = 0
    if (n >= k):
        posibility = 1/n * (n-k+1)
        for i in range(1, k):
            posibility += ((1)/(n))*((1/2)**(getCount(i, k)))
    else:
        for i in range(1, n+1):
            count = (getCount(i, k))
            posibility += 1/n*((1/2)**(getCount(i, k)))
    return posibility
        
n, k = map(int, input().split())
print(answer(n, k))

Solution (Python):
x,y=list(map(int, input().split()))
a=0
b=0
p=0
ans=0
for i in range(1,x+1):
	a=i
	p=2**20
	while a<y:
		a=a*2
		p=p/2
	ans=ans+p
print(ans/(2**20)/x)

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

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

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

probability = 0
for i in range(1,n+1):
    p = 1/n
    p_head = 1/2
    flips = 0
    prob = p * p_head**flips
    score = i
    
    while score < k:
        flips += 1
        prob = p * p_head**flips
        score = score * 2

    probability += prob


print(probability)

Solution (Python):
import math

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







ans = 0

for i in range(1, n + 1):
    v = i
    c = 0
    while True:
        if v >= k:
            ans += (1 / n) * (1 / 2)**c
            break
        v *= 2
        c += 1

print(ans)

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

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

Solution (Python):
N,K=map(int,input().split())
S=[0]*N
for i in range(0,N):
    if i+1>=K:
        S[i]=1
    else:
        for j in range(100):
            if (i+1)*(2**(j-1))>=K:
                S[i]=1/(2**(j-1))
                break
goukei=sum(S)
print(goukei/N)

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


total = 0.0

for n in range(1, N+1):
  count = 0
  in_score = n

  while (in_score < K):
    in_score *= 2
    count += 1

  total += 1 / N * (0.5)**count

print(total)

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

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

Solution (Python):

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

sum = 0
for i in range(N):
    X = math.log2(K/(i+1))
    X = math.floor(X) if X % 1 == 0 else math.floor(X+1)
    
    X = X if X > 0 else 0
    sum += (1/N)*(1/2)**X
    
print(sum)

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

    
if __name__ == '__main__':
    main()

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

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


per = 0

for i in range(N):
	
	tmp_val = i + 1

	
	tmp_cnt = 0
	while(tmp_val < K):
		tmp_val *= 2
		tmp_cnt += 1
	
	per += 1 / (N * 2**tmp_cnt)

print(per)

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

Solution (Python):

import numpy as np
n,k = map(int,input().split())
cnt = 0

m =  1/n
for i in range(1,n+1):
    
    t = np.ceil((np.log2(k) - np.log2(i)))  
    
    if i < k:
        cnt += m * (0.5)**t
    else:
        cnt += m
print(cnt)

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

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

print(ans)

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

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

    ans += 0.5**j / N

print(ans)

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

DP = [-1] * (max(N, K) + 10)
ans = 0
for i in range(1, N+1)[::-1]:
    cnt = 0
    n = i
    while n < K and DP[n] < 0:
        n *= 2
        cnt += 1
    if n < K:
        if DP[n] >= 0:
            DP[i] = (1/2) ** cnt * DP[n]
        else:
            DP[i] = (1 / 2) ** cnt
    else:
        DP[i] = (1/2) ** cnt
    ans += DP[i]
print(ans/N)

Solution (Python):
def main():
    N,K = map(int, input().split())
    
    l=[]
    
    for i in range(1,N+1):
        if i < K:
            m=i
            j=0
            while m<K:
                j+=1
                m = i*(2**j)
            l.append(1/(N*(2**j)))
        else:
            l.append(1/N)
    print(sum(l))
main()

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

Solution (Python):
import math

n, k = map(int, input().split())
prob = 0
for i in range(1,n+1):
    if i <= k-1:
        x = math.floor(1+math.log2(((k-1)/i)))
       
        prob += (1/2)**x
    else:
        prob += 1
print(prob/n)

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

def func(ini):
    
    if ini >= K:
        per = 1 / N
        return per
    count = 0
    point = ini
    while point <= K - 1:
        point *= 2
        count += 1
    per = 1 / (N * 2**count)
    return per
ans = 0
for i in range(1, N+1):
    ans += func(i)
print(ans)

Solution (Python):
def main():
    N,K = [int(x) for x in input().split()]
    prob = 0
    for i in range(N):
        dice=i+1
        coin = 0
        while dice < K:
            dice *= 2
            coin += 1
        prob += float(1/N) * 0.5**coin
    print(prob)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
import math

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
   
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

A=[]
cnt=0
def count(i,k):
    cnt=0
    while k>i:
        i=i*2
        cnt+=1
        
    return cnt

pro=0

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

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

    ans = 0

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

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from itertools import (
    accumulate, combinations, combinations_with_replacement, groupby,
    permutations, product)
from math import (
    acos, asin, atan, ceil, cos, degrees, factorial, hypot, log2, pi, radians,
    sin, sqrt, tan)
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits


def inp():
    return(int(input()))


def inlist():
    return(list(map(int, input().split())))


def instr():
    s = input()
    return(list(s[:len(s)]))


def invr():
    return(map(int, input().split()))


n, k = invr()
res = 0
for i in range(1, n+1):
    if i > (k-1):
        res += 1/n
    else:
        x = ceil(log2((k)/i))
        res += (1/n) * (1/2)**x
print(res)

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

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

ans = 0

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

ans /= N
print(ans)

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

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

lose=0
ans=0
for i in range(1,n+1):
    if i>=k:
        lose=0
        lose+=n
        ans+=float(1/lose)

    elif i<k:
        lose=0
        count=n
        while i<k:
            count*=2
            i*=2
        lose+=count
        ans+=float(1/lose)

print(ans)

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


win=0
lose=0
COUNT=0
ans=0
for i in range(1,n+1):
    if i>=k:
        win=0
        lose=0
        win+=1
        lose+=n-1
        ans+=float(win/(win+lose))

    elif i<k:
        win=0
        lose=0
        count=n
        win+=1
        while i<k:
            count*=2
            i*=2
        lose=lose+count-1
        ans+=float(win/(win+lose))

print(ans)

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

Solution (Python):
N, K = map(int, input().split())
coin = [0.5**k for k in range(10**5)]
ans = 0
for i in range(1,N+1):
    x = 0
    while(True):
        if i*(2**x) >= K:
            ans += 1/N * coin[x]
            break
        else: x += 1

print(ans)

Solution (Python):
N, K = map(int, input().split())
coin = [0.5**k for k in range(10**5)]
ans = 0
for i in range(1,N+1):
    x = 0
    while(True):
        if i*(2**x) >= K:
            ans += 1/N * coin[x]
            break
        else: x += 1

print(ans)

Solution (Python):
import math

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

for i in range(1,N+1):
    tmp = math.log(K/i, 2)
    x = int(math.log(K/i,2))
    if i >= K:
        ans += 1/N
    else:
        if tmp - x != 0:
            x += 1
        ans += 1/N * (0.5)**x

print(ans)

Solution (Python):
import decimal
import math

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

ans = 0

for i in range(1,N+1):
    tmp = math.log(K/i, 2)
    x = int(math.log(K/i,2))
    if i >= K:
        ans += 1/N
    else:
        if tmp - x != 0:
            x += 1
        ans += 1/N * (0.5)**x

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)
        continue
    X = int(math.log((K/i), 2))
    if (K/i) % 2**X == 0:
        pass
    else:
        X += 1
    ans += (1/N) * (1/2) ** X
print(ans)

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

    ans = 0
    kita = [(int(i)+1) for i in range(n)]
    for i in kita:
        tmp  = 0
        tmp2 = i
        while tmp2 < k:
            tmp2 *= 2
            tmp+=1
        ans = ans + ((0.5)**tmp)*(1/n)
    print(ans)






if __name__ == '__main__':
    main()

Solution (Python):
import math

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

for i in range(N):
    dice = max(0, math.ceil(math.log2(K / (i+1))))
    per += (1/N) * (1/2) ** dice
    
print(per)

Solution (Python):
import math
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

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

Solution (Python):
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *

from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction



mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]







n,k=l()
ans=0
for i in range(1,n+1):
    if(i<k):
        x=1
        while(i*(2**(x))<k):
            x+=1
        
        ans+=Fraction(1,n)*(Fraction(1,2)**x)
    else:
        ans+=Fraction(1,n)
print(ans.numerator/ans.denominator)

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

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

print(ans)

Solution (Python):
import math

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

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

Solution (Python):
N, K=map(int, input().split())
import math
def touhiwa(n):
  ans=0
  for i in range(1, n+1):
    r=max(0,math.ceil(math.log2(K/i)))
    ans+=0.5**(r)
  return ans
print(touhiwa(N)/N)

Solution (Python):
n,k = map(int,input().split())
s = [[i] for i in range(1,n+1)]
ans = 0

for i in s:
    x = i[0]
    c = 0
    while x < k:
        x *= 2
        c += 1
    s[i[0]-1].append(c)

for i in s:
    ans +=1/n*(1/2)**i[1]

print(ans)

Solution (Python):
import math
n,k=map(int,input().split())
"""
1～6で場合わけ
"""
log2k = math.log(k, 2)
ans = 0
for i in range(1, n+1):
	target = math.ceil(log2k - math.log(i, 2))
	if target >= 1:
		ans += 1/(2**target)
	else:
		ans += 1
print(ans/n)

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

ans = 0

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

print(ans)

Solution (Python):
N,K=map(int,input().split())
two=[i for i in range(20)]
for i in range(20):
    two[i]=2**i
res=0
for i in range(1,N+1):
    for j in two:
        if i*j>=K:
            res+=1/(j*N)
            break
print(res)

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

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

p = 0

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

print(p / n)

Solution (Python):
import math

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

for i in range(1, N+1):
  if i < K:
    cnt = math.ceil(math.log2(K / i))
    ans += (1 / N) * (1 / 2)**cnt
  else:
    ans += 1 / N

print(ans)

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

l=[]
point=k
l.append(k)
while point>1:
    if point%2==0:
        point=point//2
    else:
        point=(point//2) +1
    l.append(point)

m=len(l)

if n>=k:
    ans1=0
    for i in range(m-1):
        count=l[i]-l[i+1]
        prob=0.5**(i+1)
        ans1+=prob*count
    ans=ans1+(n-k+1)
elif n==1:
    countn=0
    nn=n
    while nn<k:
        nn=nn*2
        countn+=1
    ans=0.5**countn
else:
    ans2=0
    for i in range(m-1):
        if n>=l[i]:
            b=i
            break
        else:
            continue
        break
    ans2+=((0.5)**b)*(n-l[b]+1)
    for i in range(b,m-1):
        count=l[i]-l[i+1]
        prob=0.5**(i+1)
        ans2+=prob*count
    ans=ans2



print(ans/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 += 2 ** -cnt / N
print(ans)

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

Solution (Python):
n,k = map(int,input().split())
p = 0
q = 0
if n - k >= 0:
    p = (n - k + 1)/n
    j = 0
    for i in range(1,k):
        while k - i*(2)**j >0:
            j += 1
        q += (1/n)*(1/2)**j
        j = 0
else:
    j = 0
    for i in range(1,n+1):
        while k - i*(2)**j >0:
            j += 1
        q += (1/n)*(1/2)**j
        j = 0
print(p+q)

Solution (Python):

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)








from math import log2,ceil

n,k=n1()

ans=0
for i in range(1,min(n,k)+1):
    a=k/i
    b=0.5**ceil(log2(a))
    ans+=b

if k<n:    
    ans+=(n-k)
print(ans/n)

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

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

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

resolve()

Solution (Python):
def main():
    n, k = map(int, input().split())
    count = 0
    lc = list()
    res = 0
    for i in range(1, n+1):
        while i < k:
            i = i * 2
            count += 1
            if i >= k:
                lc.append(count)
                count = 0
    diff = n - len(lc)
    for i in range(len(lc)):
        res += 1/n * (1/2 ** lc[i])
    res += diff/n
    print(res)
if __name__ == '__main__':
    main()

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

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

resolve()

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

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

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

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 = i*2
    t += 1
  ans += (0.5**t)/n
print(ans)

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

l = [None] * N
b = 0
for i in range(1, N + 1):
    a = i
    b = 0
    while a < K:
        a *= 2
        b += 1
    l[i - 1] = b

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

print(ans)

Solution (Python):
N,K=map(int,input().split())
sum_value = 0
for i in range(1,N+1):
    if(i>=K):
        sum_value = sum_value+1/N
    else:
        for j in range(1,18):
            if(i*(2**j)>=K):
                sum_value=sum_value+((1/N)*(1/(2**j)))
                break
print(sum_value)

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

Solution (Python):
n, k = map(int, input().split())
w = max((n-k+1) / n, 0)
coin_win = 0
for i in range(1, min(k, n+1)):
    for x in range(1, 18):
        if i * (2 ** x) >= k:
            coin_win += 1 / (2 ** x)
            break
if k != 1:
    print(w + (1-w) * coin_win / min(k-1, n))
else:
    print(w)

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

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

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

x=0
ans=0

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

print(ans)

Solution (Python):

import numpy as np

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

result = []

for i in range(n):
    num = i+1
    count = 0
    while True:
        if num >= k:
            result.append(count)
            break
        num *= 2
        count += 1


prob = 0

for j in result:
    prob += (1/n) * (0.5)**j

print(prob)

Solution (Python):
import math
n,k = list(map(int, input().split()))
print(sum([(1/2)**max(math.ceil(math.log2(k/(i+1))),0)/n for i in range(n)]))

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

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

Solution (Python):
N , K = (int(a) for a in input().split())
ans = []
for i in range(N) : 
    a = i + 1
    p = 1 / N
    while  a < K :
        a = a * 2
        p = p / 2
    ans.append(p)

print(sum(ans))

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

ans = 0
cout = 0
while True:
  if N - K >= 0:
    ans += (N-K+1) / (2**cout)
    N = K - 1
  if K == 1:
    break
  K = (K+1) // 2
  cout += 1
print(ans / N_)

Solution (Python):


import math

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

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

Solution (Python):
N, K = map(int, input().split())
Psum = 0
for n in range(1,N + 1):
  point = n
  Pn = 1/N
  while(point <= (K - 1)):
    point *= 2
    Pn /= 2
  Psum += Pn
print(Psum)

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

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

Solution (Python):
from math import ceil, log2

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

if N < K:
    for n in range(1, N + 1):
        p += (1 / N) * (1 / 2) ** ceil(log2(K / n))
else:  
    for n in range(1, K):
        p += (1 / N) * (1 / 2) ** ceil(log2(K / n))
    for n in range(K, N + 1):
        p += (1 / N)

print(p)

Solution (Python):
from sys import stdin
import math
def LI(): return list(map(int,stdin.readline().rstrip().split()))

tmp = LI()
n,k = [tmp.pop(0) for _ in range(2)]
score = -1
ans = 0
for i in range(1,n+1):
    if k <= i:
        ans += 1/n
    else:
        x = math.log2(k/i)
        ix = int(x)
        if ix<x:
            ix += 1
        ans += pow(1/2,ix)/n

print(ans)

Solution (Python):
N,K=map(int,input().split())
ans=0.0
for i in range(1,N+1):
	if i>=K:
		ans+=1/N
		continue
	j=2
	while i*j<K:
		j*=2
	ans+=1/N/j
print(ans)

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

if N<K:
    total=0
    for i in range(1,N+1):
        for j in range(1000):
            if i*2**j<K<=i*2**(j+1):
                total+=(1/N)*(1/2)**(j+1)
                break
elif N>=K:
    total=0
    for i in range(K,N+1):
        total+=(1/N)*1
    for i in range(1,K):
        for j in range(1000):
            if i*2**j<K<=i*2**(j+1):
                total+=(1/N)*(1/2)**(j+1)
                break   
print(total)

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

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

result = 0
for a in B:
    result += 1/N*0.5**a

print(result)

Solution (Python):

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

ans=0
for i in range(1,N+1,1):
    point = i
    count = 0
    if i>=K:
        ans +=1
    else:
        while point < K:
            point *= 2
            count += 1
        ans += 1/(2**count)

print(ans/N)

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

probability = []

for i in range(1, N+1):
    count = 0
    while i < K:
       i = i * 2
       count += 1
    probability.append((1/N)*(1/2)**count)   

result = 0
for i in probability:
    result = result + i

print(result)

Solution (Python):
import math

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

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

Solution (Python):

import math


def main():
    n, k = map(int, input().split())
    p = 0
    for i in range(1, n + 1):
        head_num = math.ceil(math.log(k / i, 2.0))
        head_num = max(head_num, 0)
        p += 1 / n * ((0.5) ** head_num)
    print(p)


if __name__ == '__main__':
    main()

Solution (Python):
import math

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

ans = 0

if K == 1:
    print(1)
    exit()

for i in range(1, min(N+1, K)):
    
    ans += 2 ** -math.ceil(math.log2(K/i))

ans = ans/N

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

print(ans)

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    n, k = map(int, readline().split())
    ans = 0.
    for i in range(1, n+1):
        cnt = 0
        s = i
        while s<=k-1:
            s *= 2
            cnt += 1
        ans += 1/n * pow(2, -cnt)
    print('{:.12f}'.format(ans))
if __name__ == '__main__':
    main()

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

Solution (Python):
import math

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

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

Solution (Python):
import sys
import math

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007



def main():
	n, k = IN()
	
	r=0
	for i in range(1, n+1):
		a = math.ceil(math.log2(max(1,(k+i-1)//i)))
		
		ra = (1/2)**a
		r+=ra
		
		
	return r/n
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

Solution (Python):
def resolve():
    N, K = [int(i) for i in input().split()]
    import math
    ans = 0
    for i in range(1, N + 1):
        if i < K:
            coin = math.ceil(math.log2(K / i))
            ans += (1 / N) * ((1 / 2)**coin)
        else:
            ans += (1 / N)
    print(ans)


resolve()

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

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

    ans += 0.5**cnt

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

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

Solution (Python):
def c_dice_and_coin():
    from math import ceil, log2
    N, K = [int(i) for i in input().split()]

    ans = 1 / N * sum(1 / 2**max(ceil(log2(K / d)), 0) for d in range(1, N + 1))
    return round(ans, 12)

print(c_dice_and_coin())

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import fractions
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

def double(n, k):
    num = n
    cnt = 0
    while True:
        if num < k:
            cnt += 1
            num *= 2
        else:
            break
    return cnt

N, K = getNM()
ans = max(0, N - K + 1) / N
for i in range(1, min(N + 1, K)):
    prob = double(i, K)
    ans += 1 / ((2 ** prob) * N)
print(ans)