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 math
N, K = map(int, input().split())
ans = 0
for i in range(1, N+1):
    b = math.ceil(K / i-1).bit_length()
    ans += 1/pow(2, b)
print(ans/N)

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

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

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

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

print(sum(prob))

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

print(sum(prob))

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

print(sum(prob))

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

print(ans)

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

ans = 0

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

ans/=n

print(ans)

Solution (Python):


import collections
import itertools

def main():
    n, k = input_list()
    res = 0.0
    for v in range(n):
        i = v + 1
        t = 1.0
        ii = i
        while ii < k:
            ii *= 2
            t /= 2.0
        res += t

    res /= n
    print(res)


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


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()

Solution (Python):

import sys


def solve(N: int, K: int):
    ans = 0
    for n in range(1, N+1):
        b = 1
        while n * b < K:
            b <<= 1
        ans += 1 / (b * N)
    return ans


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    K = int(next(tokens))  
    print(solve(N, K))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    
    main()

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

per = 0

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

print(per)

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*0.5**(math.ceil(math.log2(K/i)))
  else:
    ans+=1/N
    
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

if k == 1:
    print(1)
    sys.exit(0)














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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

if k == 1:
    print(1)
    sys.exit(0)

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

Solution (Python):


def main():
    n, k = map(int, input().split())
    ans = 0.0
    for t in range(1, n + 1):
        cnt = 0
        now = t
        per = 1.0
        while now < k:
            per /= 2
            now *= 2
        ans += per / n
    print('{:.20}'.format(ans))
    pass


if __name__ == '__main__':
    main()

Solution (Python):

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

nino_ijo=[0]*21
for i in range(21):
    nino_ijo[i] = 2**i


out=0
for i in range(1,N+1):
    
    for j in range(21):
        if i*(2**j) >= K:
            out += (1/N) * ((1/2)**j)
            break
    
print(out)

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

Solution (Python):


import math
N,K = map(int,input().split())
P = 0
for i in range(1,N+1):
    if i >= K:
        P += 1/N
    else:
        P += (1/N)*(0.5)**(math.ceil(math.log(K/i,2)))
        
print(P)

Solution (Python):
def abc126c():
    import math
    n, k = map(int, input().split())
    ans = 0.0
    for i in range(1, n + 1):
        v = max(0, math.ceil(math.log2(k / i)))
        ans += math.pow(0.5, v)
    print(ans/n)


abc126c()

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


pows = [1]
while pows[-1] < k:
    pows.append(2 * pows[-1])

ans = 0
ind = -1
for i in range(1, n + 1):
    if -ind < len(pows) and pows[ind-1] * i >= k:
        ind -= 1
    ans += pows[-ind - 1]

print(ans / (pows[-1] * n))

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


def func1(i, k):
    ans = 0
    num = i
    end = False
    if num >= k:
        return 0
    while(not end):
        ans += 1
        num *= 2
        if num >= k:
            end = True
            break
    return ans


ans = 0
for initial_score in range(1, N+1):
    ans += (1/N) * (1/2) ** func1(initial_score, K)
print(ans)

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



while (A <= N):
  count = 0
  T = A
  while (T<K):
    T = T*2
    count += 1
  ans += float((1/N)*(1/2)**count)
  A += 1
  
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)
        continue
    x = 1
    while 1:
        i *= 2
        if i>=k:
            break
        else:x+=1
    ans += (1/n)*(1/2)**x
print(ans)

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

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

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

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

import math

prob = 0
for i in range (1, N+1):
	if i>=M:
		prob+=1/N
	else:
		prob+=((1/N)*1/2**math.ceil(math.log(M/i, 2)))

print(prob)

Solution (Python):
from math import *

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

ans = 0
for i in range(1, n+1):
  tmp = 1 / n
  if i < k:
    tmp *= 0.5 ** ceil(log2(k/i))
  ans += tmp

print(ans)

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

sum : float = 0.0
for i in range(1,n+1):
    ret : float = 1/n
    tmp = i
    while(tmp < k):
        tmp *= 2
        ret /= 2
    if(tmp != 0):
        sum += ret 
print(sum)

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

import math

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

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

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

ans = 0

for i in range(1, N + 1):
  if i >= K:
    ans += (1 / N)
  else:
    temp = math.log(K / i, 2)
    nu = pow(2, math.ceil(temp))
    ans += (1 / (nu * N))
print(ans)

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

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

Solution (Python):
N,K = map(int,input().split())
tmp = 1
num_cnt = 0
while K > tmp :
  tmp *= 2
  num_cnt +=1
nums_list = []
for i in range(1,N+1):
  for j in range(num_cnt+1):
    if i*(2**j) >= K:
      nums_list.append(((1/2)**j))
      break
print(sum(nums_list)*(1/N))

Solution (Python):
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mat = lambda x, y, v: [[v]*y for _ in range(x)]
ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

N, K = rl()

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

Solution (Python):

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

print(answer/N)

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

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

Solution (Python):
n,k = map(int, input().split())
a=[]
while k>1:
    a.append(k)
    k/=2
a.append(k/2)
ans=0
c=0
b=n
while n>=1:
    if n>=a[c]:
        ans+=(2**(-c))*(1/b)
        n-=1
    else:
        c+=1
print(ans)

Solution (Python):
import math

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

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

Solution (Python):

"""
Created on Sat Sep 12 23:11:33 2020

@author: liang
"""

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

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

Solution (Python):
import math
n,k = map(int, input().split())
s = 0
ans = 0
for x in range(1,n+1):
  if x >= k:
    a = 0
  else:
    a = math.ceil(math.log2(k/x))
  b = (1 / n) * ((0.5) ** a)  
  ans += b
  
   
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
print(ans/N)

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

ans = 0

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

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
        continue
    cnt = 0
    now = i
    while now < k:
        cnt += 1
        now *= 2
    ans += (1/n)*(1/2)**cnt
print(ans)

Solution (Python):
import math

def main():
    N, K = map(int, input().split())
    prob = 0
    for i in range(1, N+1):
        if K / i <= 1:
            prob += 1
        else:
            coin = math.ceil(math.log2(K / i))
            prob += 0.5 ** coin
    print(prob / N)


if __name__ == '__main__':
    main()

Solution (Python):

import sys
import math
import decimal
import itertools
from itertools import product
from functools import reduce
def input():
    return sys.stdin.readline()[:-1]
def sort_zip(a:list, b:list):
    z = zip(a, b)
    z = sorted(z)
    a, b = zip(*z)
    a = list(a)
    b = list(b)
    return a, b

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

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


if __name__ == '__main__':
    main()

Solution (Python):
import math
N,K = map(int,input().split())
prob = 0
for i in range(1,N+1):
    win_seq = max(math.ceil(math.log2(K/i)),0)
    prob += (1/2)**win_seq
print(prob/N)

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

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

ans *= 1/N

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

print("{:.10f}".format(ans))

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

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

Solution (Python):
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right 
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

N,K = mint()
ans = 0

def div2(x):
    k = 0
    while x<K:
        k += 1
        x *= 2
    return k

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

Solution (Python):
D, P = map(int, input().split())    
ans = 0.0
def func(i):
    t = 0
    while(i < P):
        i *= 2
        t += 1
    return t

for i in range(1, D + 1):
    ans += float((1/D)) * float(((1 / 2) ** func(i)))

print(ans)

Solution (Python):




INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    n,k=INTM()
    ans=0
    for i in range(1,n+1):
        temp=i
        ct=0
        while temp<k:
            ct+=1
            temp*=2
        ans+=(1/(n*(2**ct)))
    
    print(ans)


if __name__=='__main__':
    do()

Solution (Python):
import math

n, k = map(int, input().split())
ans = 0
x = [max(0, math.ceil(math.log2(k / i))) for i in range(1, n + 1)]
for i in x:
    ans += ((2 ** i) * n) ** -1 
print(ans)

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

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

ans = 0

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

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:
        x = 0
        while i < K:
            i *= 2
            x += 1
        ans += (1/N) * (1/2)**x
print(ans)

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

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

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

print(ans)

Solution (Python):
import math

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

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

print(ans)

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

Solution (Python):
from math import log2
import decimal

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

decimal.getcontext().prec = 28

ans = decimal.Decimal(0)

for i in range(1, N+1):
    if i < K:
        power = -(-(log2(K) - log2(i))//1)
        prob = decimal.Decimal(1/((2**power) * N))
    else:
        prob = decimal.Decimal(1/N)

    
    ans = decimal.Decimal(ans + prob)
    

print(ans)

Solution (Python):
from math import log2
import decimal

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

decimal.getcontext().prec = 28

ans = decimal.Decimal(0)

for i in range(1, N+1):
    if i < K:
        power = -(-(log2(K) - log2(i))//1)
        prob = decimal.Decimal(1/((2**power) * N))
    else:
        prob = decimal.Decimal(1/N)

    
    ans = decimal.Decimal(ans + prob)
    

print(ans)

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

num = 0

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

print(num)

Solution (Python):
def mapt(fn, *args):
    return tuple(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))


def func(i, k):
    count = 0
    while i < k:
        i *= 2
        count += 1
    return count


def main():
    n, k = Input()
    ans = 0
    for i in range(1, n+1):
        ans += 1/n * (1/2 ** func(i, k))
    print(ans)


main()

Solution (Python):
r=input().split()
N=int(r[0])
K=int(r[1])
ans=0
for i in range(1,N+1):
    x=i
    n=0
    while x<=K-1:
        x=x*2
        n+=1
    ans+=(1/N)*((1/2)**n)
print(ans)

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

Solution (Python):
def p(n, k):
    if n >= k:
        return 1
    num = 0
    while n < k:
        n *= 2
        num += 1
    return 1 / 2 ** num

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

ans = 0
for n in range(1, N + 1):
    ans += p(n, K)

ans /= N

print(ans)

Solution (Python):
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())


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

print(ans)

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

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

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

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

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

Solution (Python):
import sys

N, K = map(int, sys.stdin.readline().split())
ans = 0
for i in range(1, N+1):
    if K <= i:
        ans += 1 / N
    else:
        count = 0
        while i < K:
            count += 1
            i *= 2
        ans += (1 / N) * 0.5 ** count

print(ans)

Solution (Python):
def LI():
    return list(map(int, input().split()))


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

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

ans= 0
from math import ceil,log2

for i in range(1,n+1):
    if i<k:
        a = ceil(log2(k/i))
        ans +=(1/n)*(1/2)**a
    else:
        ans += (1/n)

print(ans)

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

Solution (Python):
def main():
    N,K = map(int,input().split())
    ans = 0
    dict = {}
    cnt = 0
    tmp = 1/N
    for i in range(N,0,-1):
        i = float(i)
        if K <= i:
            ans += tmp*(0.5**cnt)
        else:
            while True:
                K = K/2
                cnt += 1
                if K <= i:
                    break
            ans += tmp*(0.5**cnt)
    return ans

print(main())

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

ans = 0
for i in range(1, n + 1):
    j = i
    cnt = 1
    while j < k:
        j <<= 1
        cnt /= 2
    ans += cnt / n
print('{:10}'.format(ans))

Solution (Python):
import math
N,K = map(int,input().split())
P = max((N-K+1)/N,0)
cnt = 0
for k in range(1,min(N,K-1)+1):
    cnt += 2**(-math.ceil(math.log2(K/k)))
cnt = cnt/N
P += cnt
print(P)

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

ans = 0
j = 1.0
for x in range(N, 0, -1):
    if x >= K:
        ans += 1.0 * (1 / N)
    else:
        while x * j < K:
            j *= 2.0
        ans += (1.0 / j) * (1 / N)
print(ans)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()
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):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))


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

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 / (n * 2**cnt)

print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  
def LS2(): return list(sys.stdin.readline().rstrip())  


N,K = MI()
ans = 0
if N >= K:
    ans += (N-K+1)/N
for i in range(1,min(K-1,N)+1):
    a = i
    r = 0
    while a <= K-1:
        a *= 2
        r += 1
    ans += 1/(N*2**r)

print(ans)

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

ans = 0
twol = [0]*20
for i in range(1,n+1): 
    two = 0
    curr_i = i
    for i in range(20):
        if curr_i >= k: break
        curr_i *= 2
        two += 1
    twol[two] += 1

ans = 0
for two, cnt in enumerate(twol):
    ans += cnt/pow(2,two)
    
ans /= n
print(ans)

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

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

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

Solution (Python):
import math

N, K = [int(x) for x in input().split()]

S = 0
for i in range(1, N + 1):
    a = 0
    while i < K:
        a += 1
        i *= 2
    S += 0.5 ** a

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

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

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

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

p = 1/n

ans = 0
for result in range(1, n+1):
    
    k = K
    k /= result
    cnt = 0
    while k > 1:
        k /= 2
        cnt += 1
    ans += p * (0.5)**cnt
print(ans)

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

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

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

p = 0

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

print(p)

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

ans = 0

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

print(ans)

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

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

    ans += 1 / (N * 2 ** x)

print(ans)

Solution (Python):

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

ans = 0
for i in range(1,N+1):
    if K//i != 0:
        a = math.log2(K/i)
        if a.is_integer():
            x = int(a)
        else:
            x = int(a) + 1
        ans += (1/N)*(1/2)**x
    else:
        ans += (1/N)
print(ans)

Solution (Python):
import math

n, k = map(int, input().split())
log2 = math.log10( 2)
ans = 0
for i in range(1,n+1):
    temp = i
    num = 1/n
    while temp < k:
        num /= 2
        temp *= 2
    ans += num

print(ans)

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

P = [1/N] * N

for i in range(N):
  score = i+1
  while score < K:
    score *= 2
    P[i-1] /= 2

print(sum(P))

Solution (Python):
import math
a = [int(s) for s in input().split()]
saikoro = a[0]
tensu = a[1]
ans = float(0)

for i in range(1, saikoro+1):
    if i >= tensu:
        ans += 1
    else:
        temp = tensu / i
        temp2 = math.ceil(math.log(temp, 2))
        ans += (1 / int((2 ** temp2)))

print(ans / saikoro)

Solution (Python):
import sys



def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


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


if __name__ == "__main__":
    main()

Solution (Python):
N, K = map(int, input().split())
ans = 0.0
for n in range(1, N+1):
  m = n
  a = 1
  while m < K:
    m <<= 1
    a /= 2
  ans += a
print(ans / N)

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


def coincnt(base,k):
    ans = 0
    while base<k:
        ans+=1
        base*=2
        
    return ans

p=0.0
for i in range(1,n+1):
    p+=(1/n)*(1/2)**coincnt(i,k)
    
print(p)

Solution (Python):
N,K=map(int,input().split())
k = 0
res = 0
flag = True
for i in range(1,N+1):
  flag = True
  mid = 1/N
  k = i
  if k >=K:
    pass
  else:
    while k<K:
      mid = mid*0.5
      k = k*2
  res += mid
print(res)

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

p = 0
q = 0
for j in range(N,0,-1):
  while j*(2**q) < K:
    q += 1
  p += 0.5**q
print(p*(1/N))

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

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

def return_prob(x):
  if K <= x:
    return 1
  else:
    return 1 / (2 ** math.ceil(math.log2(K/x)))

prob = 0
for i in range(1, N+1):
  prob += return_prob(i)
prob /= N
print(prob)

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


for i in range(1,N+1):
    count = 0
    point = i
    while(point <= K-1):
        point = point * 2
        count += 1
    possibility += 0.5**count

print(possibility / N)

Solution (Python):
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n,k = LI()
    num = 0
    frac = 0
    while n * 2**num < k:
        num+=1
    frac += 1/2**num
    

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

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

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

Solution (Python):
import math
from fractions import Fraction


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

n,k=input2()
ans=0
for i in range(1,n+1):
	point=i
	if point>=k:
		ans+=Fraction(n-point+1,n)
		break
	else:
		tmp=math.ceil(math.log2((k/point)))
		ans+=Fraction(1,n)*Fraction(1,2**tmp)
print(float(ans))

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

ans = 0.0
for x in range(1, n + 1):
    y = x
    m = 0
    while y <= k - 1:
        m += 1
        y *= 2
    ans += 1 / (2 ** m)
print(ans / n)

Solution (Python):
import math
N,K=map(int,input().split())
pro=0
if N==1 and K==1:
    print(1)
elif N>=K:
    pro+=(N-K+1)/N
    for k in range(1, K):
        r = math.ceil(math.log(K / k,2))
        pro += 0.5**r / N
    print(pro)

else:
    for k in range(1, N+1):
        r = math.ceil(math.log(K / k,2))
        pro += 0.5**r / N
    print(pro)

Solution (Python):
n, k = map(int, input().split())
arr = []
for i in range(n):
  c = i + 1
  p = 1 / n
  while 1 <=  c <= k - 1:
    c *= 2
    p *= 0.5
  arr.append(p)
ans = sum(arr)
print(ans)