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())

pow2 = [2**i for i in range(50)]

ans = 0

for i in range(1,N+1):
    for j in range(len(pow2)):
        if K <= i*pow2[j]:
            
            ans += 1/pow2[j]
            break
ans *= (1/N)
print(ans)

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

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

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

ans = 0
for i in range(1, N+1):
  cnt, score = 0, i
  if i >= K:
    ans += 1.0/N
  else:
    while score < K:
      score *= 2
      cnt += 1
    ans += (1.0/N) * (1/2)**cnt
print(ans)

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

Solution (Python):

import sys
import math
import os
import itertools
import _collections
import string

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

def main():
    N,K = cin.mapInt()
    ans = 0
    for i in range(1,N + 1):
        ans += (1.0 / Math.nearPow2(math.ceil(K / i)))
    ans /= N
    print(ans)
    return

if __name__ == "__main__":
    main()

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

for i in range(1, N+1):
        ten = i
        ratio = 1.0 / N
        while ten < K:
                ten *= 2
                ratio *= 0.5
        sum_ratio += ratio

print(sum_ratio)

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

Solution (Python):
from __future__ import print_function

import sys
input = sys.stdin.readline






import math


from fractions import Fraction





























def crange(a, b, i):
    return range(a, b + 1, i)


def main():
    n, k = map(int, input().split())
    p12 = Fraction(1, 2)
    ans = 0
    for i in crange(1, n, 1):
        if i >= k:
            ans += 1
        else:
            ans += p12**(math.ceil(math.log(Fraction(k, i), 2)))
    print(float(Fraction(ans, n)))
    
    


if __name__ == '__main__':
    main()

Solution (Python):

import math
import sys
input = sys.stdin.readline


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

    result = 0
    if n < k:
        for i in range(1, n + 1):
            x = math.ceil(math.log(k / i, 2))
            result += (1 / n) * (0.5 ** x)
    else:
        for i in range(1, k):
            x = math.ceil(math.log(k / i, 2))
            result += (1 / n) * (0.5 ** x)
        result += (n - k + 1) / n
    print(result)


if __name__ == '__main__':
    main()

Solution (Python):

import math
import sys
input = sys.stdin.readline


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

    result = 0
    if n < k:
        for i in range(1, n + 1):
            x = math.ceil(math.log(k / i, 2))
            result += (1 / n) * (0.5 ** x)
    else:
        for i in range(1, k):
            x = int(math.log(k / i, 2)) + 1
            result += (1 / n) * (0.5 ** x)
        result += (n - k + 1) / n
    print(result)


if __name__ == '__main__':
    main()

Solution (Python):
a,b = map(int,input().split())
ans = 0
for i in range(1,a+1):
  c = 0
  bai = b/i
  while bai > 1:
    bai /= 2
    c += 1
  ans += 1/(2**c)
print(ans/a)

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

print(ans)

Solution (Python):
N, K = [int(i) for i in input().split()]
ans = 0
for i in range(1, N + 1):
    tmp = 1.0 / N
    now = i
    while now < K:
        now *= 2
        tmp /= 2
    ans += tmp

print(ans)

Solution (Python):
N, K = [int(i) for i in input().split()]
ans = 0
for i in range(1, N + 1):
    tmp = 1.0 / N
    now = i
    while now < K:
        now *= 2
        tmp /= 2
    ans += tmp

print(ans)

Solution (Python):
import math

def solve(n, k):
    f = lambda i: 1 / 2 ** math.ceil(math.log2(k / i))
    return sum(1 / n * (1 if k <= i else f(i)) for i in range(1, n + 1))

_n, _k = map(int, input().split())
print(solve(_n, _k))

Solution (Python):
n, k = map(int, input().split())
total_prob = 0
for i in range(1, n+1):
  dice_count = 0
  while (i << dice_count) < k:
    dice_count += 1
  
  total_prob += (1 / n) * (0.5 ** dice_count)
  
print(round(total_prob, 12))

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

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

iniarray = np.arange(1,N+1)
mask1 = iniarray < K
mask2 = 1 - mask1
prob_array = 1/2**np.ceil(np.log2(float(K)/iniarray))
ans = (prob_array * mask1 + mask2).sum() / float(N)

print(ans)

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

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

Solution (Python):
from sys import stdin
N, K = [int(i) for i in stdin.readline().rstrip().split()]
output = 0
for n in range(1, N + 1):
    first_score = n
    now_score = n
    front_count = 0
    while now_score < K:
        front_count += 1
        now_score *= 2
    output += ((1/2) ** front_count) / N
print(output)

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

import math

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

Solution (Python):
import os, sys, re, math

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

if K == 1:
    print(1)
else:
    lk = math.log2(K - 1)
    p = 0
    for i in range(1, N + 1):
        if i >= K:
            p += 1.0
        else:
            p += (0.5 ** (int(lk - math.log2(i) + 1)))
    print(p / N)

Solution (Python):
n, k = [int(a) for a in input().split()]
ret = 0
for a in range(1, n + 1):
	cnt = 0
	tmp = a
	while(True):
		if tmp >= k:
			ret += 1/n * pow(1/2, cnt)
			break
		else:
			tmp *= 2
			cnt += 1
print(ret)

Solution (Python):
import math
N, K = [int(s) for s in input().split(' ')]
ret = [1] * N
for n in range(1, N + 1):
    p = n
    rate = 1
    if p > K - 1:
        ret[n - 1] = rate
        continue
    for i in range(100000):
        p *= 2
        rate /= 2
        if p > K - 1:
            ret[n - 1] = rate
            break

print(sum(ret) / len(ret))

Solution (Python):
n, k = map(int, input().split())
ret = 0.0
p = 1.0
r = n + 1
while True:
    num = r - min(r, k)
    ret += num * p
    r   -= num
    if k == 1:
        break
    k = (k + 1) // 2
    p = p * 0.5
print(ret / n)

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

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

Solution (Python):
import numpy as np 

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

ans = 0
for i in range(1,N+1):
    if i>=K:
        p = 0
    else:
        p = np.ceil(np.log2(K/i))
    ans += (0.5**p)/N

print(ans)

Solution (Python):
import math

n,k =  map(int,input().split())
lis = []
for i in range(n):
    if i+1 >= k:
        lis.append(0)
    else:
        lis.append(math.ceil(math.log2((k/(i+1)))))




ans = []
for i in range(n):
    ans.append(1/n * (1/2)**lis[i])

print(sum(ans))

Solution (Python):
import math
N,K = map(int,input().split())
p = 0
def f(n):
  return n*2

for i in range(N+1):
  if i !=0:
    n = 0
    while(True):
      if i >= K:
        break
      i = f(i)
      n+=1
    p += (1/N)*(0.5)**n
print(p)

Solution (Python):


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

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

Solution (Python):
import numpy as np
n, k = map(int, input().split())
dice = np.arange(1, n+1)

m = np.ceil(np.log2(k) - np.log2(dice))
for i in range(n):
    if m[i] <= 0:
        m[i:] = 0
        break
p = (0.5**m)
print(sum(p)/n)

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

ans=0
n=20
p=[1]*n
for i in range(n-1):
    p[i+1]=p[i]*2

for i in range(1,N+1):
    temp=0
    for j in range(n):
        if i*p[j]>=K:
            temp=j
            break
    ans+=1/N/p[temp]
    
print(ans)

Solution (Python):
from math import log2,ceil

def main():
    N,K = map(int,input().split())
    ans = 0
    for i in range(1,N + 1):
        digit = ceil(log2(K) - log2(i)) if K > i else 0
        ans += (1/N)*(0.5**digit) 
    print(ans)
    return

if __name__ == "__main__":
    main()

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


for x in range(1,N+1):
    bekicount = 0
    y = x
    while y < K:
        y = y*2
        bekicount = bekicount +1
    probability = probability + (1/N)*(pow(0.5,bekicount))
    bekicount = 0
print(probability)

Solution (Python):





















def calcNeedCount(n, k):
    i = 0;
    val = n;
    while (val<=k-1) :
        val = val * 2
        i = i+1
    return i
        

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

res = 0.0

for n in range(1, N+1):
    needCount = calcNeedCount(n, K)
    per = (1.0/float(N)) * pow(0.5, needCount)
    res = res + per

print(res)

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n, k = map(int, input().split())
    s = 0
    while 2 ** s < k:
        s += 1

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

if __name__ == '__main__':
    main()

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

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

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

print(ans)

Solution (Python):
from math import ceil, log2

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

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

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

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



p = 0
for i in range(1, n+1):
  if k <= i:
    p += 1/n
    continue
  a = math.ceil(math.log(k/i, 2))
  p += 1/n * 1/2**a
print(p)

Solution (Python):
import math
import sys
import numpy as np

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

n, k = int_input()

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

Solution (Python):
import math
N,K = map(int, input().split())
ret = 0.0
for i in range(1,N+1):
    
    log_2_K_n = math.ceil(math.log2(K/i))
    ret += (1/N)*((0.5)**log_2_K_n if i < K else 1)
    
    
print(ret)

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

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

Solution (Python):
import sys
input = sys.stdin.readline
 
def main():
    N, K = list(map(int, input().split()))
 
    ans = 0
    for i in range(1, N+1):
        t = 0
        while i < K:
            i *= 2
            t += 1
 
        ans += 0.5 ** t
 
    print(ans * (1 / N))
 
 
if __name__ == '__main__':
    main()

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

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

print(ans)

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

    res = 0
    for i in range(1,n+1):
        cnt = 0
        while i < k:
            i *= 2
            cnt += 1
        res += 1 / (n*(2**cnt))
    print(res)
    
if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
import math
def calculate(n,k):
    res = 0
    for i in range(n):
        indexN = i + 1

        temp = k / indexN

        if temp < 1:
            res = res + (1/n)
        else:
            t = math.log(temp,2)
            t = math.ceil(t)
            res = res + (1/n) * math.pow(0.5,t)

    print("{:.12f}".format(res))

S = input()
S = S.split(" ")
n = int(S[0])
k = int(S[1])

calculate(n,k)

Solution (Python):

from math import log2, ceil
N, K = map(int, input().split())
ans = 0
for i in range(N):
    tmp = i+1
    x = 0
    while tmp < K:
        tmp *= 2
        x += 1
    ans += 1/N * (0.5**x)
print(ans)

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

Solution (Python):
import math

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


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


print(ans)

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

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



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

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

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

Solution (Python):
n,k=map(int,input().split())
ans=0
for i in range(1,n+1):
    temp=i
    count=0
    while temp<k:
        temp=temp*2
        
        count+=1
    ans+=0.5**count
print('{:.11f}'.format(ans/n))

Solution (Python):

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

prob = 0
for i in range(1, n+1):
    num = i
    tmpprob = 1 / n
    while num < k:
        num *= 2
        tmpprob /= 2
    prob += tmpprob

print(prob)

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

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

    ans += 1/N * 1/pow(2, cnt)

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

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

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

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

        ans += 0.5 ** t

    print(ans * (1 / N))


if __name__ == '__main__':
    main()

Solution (Python):

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





answer = 0
if N < K :
    for i in range(1, N+1):
        temp = i
        cnt_temp = 0
        while temp < K:
            temp *= 2
            cnt_temp += 1
        answer += (1/N)*(1/2)**(cnt_temp)
else:
    for i in range(1, K):
        temp = i
        cnt_temp = 0
        while temp < K:
            temp *= 2
            cnt_temp += 1
        answer += (1/N)*(1/2)**(cnt_temp)
    for i in range(K, N+1):
        answer += (1/N)
print(answer)

Solution (Python):


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

result = 0
count = 0
for n in reversed(range(1, N + 1)):
	while(True):
		if n >= K:
			result += (1 / N) * (0.5 ** count)
			break
	
		K /= 2
		count += 1

print(result)

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



res = []

for i in range(1, N + 1):
    
    if i >= K:
        res.append(1 / N)
        continue
    else:
        x = 1
        while i < K:
            x = x * 0.5
            i = i * 2
        l = (1/N) * x
        res.append(l)

print(sum(res))

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

ans = 0
for n in range(N):
    a = n + 1
    c = 0
    while a < K:
        a *= 2
        c += 1
    ans += (1 / N) * (0.5 ** c)
print(ans)

Solution (Python):
n, k = (int(x) for x in input().split())
ans = 0
if n >= k:
    lim = k
    ans += (n - k + 1)/n
else: lim = n + 1
for i in range(1, lim):
    num = i
    cnt = 0
    while num < k:
        num *= 2
        cnt += 1
    ans += (0.5 ** cnt) / n
print(ans)

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

p = 0.0
for n in range(1, N + 1):
    if K <= n:
        p += 1 / N
    else:
        t = 0
        while n < K:
            n <<= 1
            t += 1
        p += 1 / N * 0.5 ** t
print(p)

Solution (Python):
def func(n,K):
   i=0
   while n*2**i<K:
      i+=1
   return i


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

count=0
for n in range(1,N+1):
   count+=(1/N)*(1/2)**func(n,K)

print(count)

Solution (Python):
n,k=map(int,input().split())
ans=0
for i in range(1,n+1):
    if i>=k:
        ans+=1/n
    else:
        cnt=1/n
        while i<k:
            cnt*=(1/2)
            i=2*i
        ans+=cnt
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:
        cnt=1/n
        while i<k:
            cnt*=(1/2)
            i=2*i
        ans+=cnt
print(ans)

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

ans = 0

for i in range(1, n+1):
    m = i
    cnt = 0
    for j in range(1, 101):
        if m >= k:
            break
        else:
            m = m * 2
            cnt += 1
    ans += (1 / n) * (0.5**cnt)

print(ans)

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


if __name__ == '__main__':
    main()

Solution (Python):
from math import log2, ceil


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

ans = 0
for m in range(1, N + 1):
    if m >= K:
        ans += 1 / N
    else:
        y = ceil(log2(K / m))
        prob = (0.5 ** y) / N
        ans += prob

print(ans)

Solution (Python):

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

def bichk(n,K):
    
    a=0
    while 1:
        if n*(2**a)>=K:
            return(a)
            break
        a+=1
if N<K:
    for i in range(1,N+1):
        ans+=(1/N)*(0.5**bichk(i,K))
else:
    ans+=(N-K+1)/N
    for i in range(1,K):
        ans+=(1/N)*(0.5**bichk(i,K))
print(ans)

Solution (Python):
def kakuritu(N, n, K):
    t = 1
    count = 0
    while N * t < K:
        t = t * 2
        count += 1
    return count

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

n = 1
kt = 0
for i in range(1,N+1):
    kt += (1 / N) * ((1/2)**kakuritu(i, n, K))
    n += 1

print(kt)

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):
n,k = map(int,input().split())
chance = 0
for i in range(1,n+1):
    
    count = 0
    while i < k:
        i *= 2
        count += 1
    
    chance += 1/n*(0.5)**count
print(chance)

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

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

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

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

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

ans = 0
cnt = 0

for n in range(1, N+1):
    c = 0
    while True:
        total = n * 2 ** c
        if total >= K:
            ans += 0.5 ** c / N
            break
        c += 1

print(ans)

Solution (Python):
import math
N, K = map(int, input().split())
prob = []
for i in range(N):
  if i+1 >= K:
    prob.append(1)
  else:
    temp = i+1
    x = 0
    while temp < K:
      temp *=2
      x += 1
    prob.append(0.5**x)
Answer = sum(prob)/N

print(Answer)

Solution (Python):
import math

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

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

print(p)

Solution (Python):
from math import log2
from math import ceil
n,k=map(int,input().split())
p=0


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

print(p)

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

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

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

t = []

if K > N:
  max = N
  for i in range(max):
    t.append(math.ceil((math.log10(K) - math.log10(i+1))/math.log10(2)))
else:
  max = K
  for i in range(max):
    t.append(math.ceil((math.log10(K) - math.log10(i+1))/math.log10(2)))
  for i in range(N - K):
    t.append(0)

Answer_n = 0
for item in t:
  Answer_n += 0.5**item

Answer = Answer_n / N

print(Answer)

Solution (Python):
import math

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


prob = 0
for m in range(1, n + 1):
    if m >= k:
        prob += 1 / n
    else:
        p = math.ceil(math.log(k / m) / math.log(2))
        prob += (1 / n) / (2 ** p)

print(prob)

Solution (Python):
import math


n, k = [int(i) for i in input().split()]
prob = 0
for i in range(1, n + 1):
    if i >= k:
        exp = 0
    else:
        exp = math.ceil(math.log2(k) - math.log2(i))
    prob += (1 / n) * (1 / 2) ** exp
print(prob)

Solution (Python):
N,K=map(int,input().split())
cnt=0
A=[0]*(N)

for i in range(N):
  cnt=0
  p=i+1
  for j in range(17):
    if p<K:
      p*=2
      cnt+=1
      if p>=K:
        A[i]=cnt
        break

ans=0
for i in A:
    ans+=(1/N)*((0.5)**i)
    
print(ans)

Solution (Python):
N,K = list(map(int,input().split(" ")))
import math
total = 0
for i in range(1,N + 1):
    if i < K:
        T = math.ceil(math.log(K / i,2))
    else:
        T = 0
    total += 1 / (N * 2 ** T)
print(total)

Solution (Python):
import math

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


prob = 0
for m in range(1, n + 1):
    if m >= k:
        prob += 1 / n
    else:
        p = math.ceil(math.log(k / m) / math.log(2))
        prob += (1 / n) / (2 ** p)

print(prob)

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

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

import math


sum_prob=0

for i in range(1,N+1):
    ratio =  K / i


    power = math.ceil(math.log2(ratio))
    if power <= 0:
        sum_prob+=1/N
        continue
    sum_prob += (1/(2**power ))/ N


print(sum_prob)

Solution (Python):

import math
import heapq
import bisect
import numpy as np


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

ans = 0
if N >= K:
    ans += (N-K+1)/N
    M = K-1
else:
    M = N
cnt = 1

while K>1:
    K = math.ceil(K/2)
    if K <= M:
        ans += (M-K+1)/((2**cnt)*N)
        M = K-1
        cnt += 1
    else:
        cnt += 1

print(ans)

Solution (Python):
N, K = map(int, input().split())
tmp = 0
for x in range(1, N + 1):
    a = 0
    n = 0
    while K > x:
        x *= 2
        n += 1
    p = 1 / N * (1 / 2 ** n)
    tmp += p
print(tmp)

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

w = n - k + 1

if n < k:
    l = n
else:
    l = k - 1

C = []
for i in range(1, l + 1):
    c = 0
    while i < k:
        i *= 2
        c += 1
    C.append(c)

ans = 0
for c in C:
    ans += (1 / n) * (1 / 2)**c
if w > 0:
    ans += w / n

print(ans)

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

w = n - k + 1

if n < k:
    l = n
else:
    l = k - 1

C = []
for i in range(1, l + 1):
    c = 0
    while i < k:
        i *= 2
        c += 1
    C.append(c)

ans = 0
for c in C:
    ans += (1 / n) * (1 / 2)**c
if w > 0:
    ans += w / n

print(ans)

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

Solution (Python):
import numpy as np
n,k = map(int, input().split())

two = 0
for i in range(1, n+1):
    two_count =0
    score = i
    while score <= k-1:
        score *= 2
        two_count += 1

    two += (1/2) ** two_count

print((1/n) * two)

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

ans /= n

print(ans)

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

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

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

print(ret)

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

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

Solution (Python):
import math

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

def bunbo(N):
    return 1/N

def n_calc(n, K):
    A = math.log10(K/n)/math.log10(2)
    A = A + 0.9999999999
    A = int(A)
    return A

def calc(N, K):
    result = 0
    const = 1/N
    for i in range(1, N+1):
      c = n_calc(i, K)
      if c < 0:
        c = 0
      result += (const * ((1/2)**c))
    return result
  
print(calc(N, K))

Solution (Python):
from math import log2, ceil
N, K = map(int, input().split())
print("{:.12f}".format(sum(min(1, 1/2**ceil(log2(K/i))) for i in range(1, N+1))/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/N
  
  else:
    m = math.ceil(math.log2(K/n))
    ans += (1/N)*(0.5**m)

print(ans)

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

Solution (Python):
import math

n, k = map(int, input().split())
ans = []
for i in range(1, n+1):
    wins = 0
    score = i
    while True:
        if score >= k:
            break
        score *= 2
        wins += 1
    ans.append(pow(0.5, wins))
print(sum(ans)/len(ans))

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

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

Solution (Python):

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

def check_double(n, K):
    count = 0
    while n < K:
        n *= 2
        count += 1
    return count

for i in range(1, N+1):
    possibility += (1/N) * (0.5 ** check_double(i, K))

print(possibility)