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 decimal
n, k = map(int, input().split())

cnt = 0
sumcl = []

for i in range(1,n+1) :
    pro = i
    while True :
        if pro < k :
            pro *= 2
            cnt += 1
        else :
            if i == 1 :
                top = cnt
                sumcl.append(1)
            else :
                sumcl.append(2**(top-cnt))
            cnt = 0
            break


print(decimal.Decimal(sum(sumcl)/(n*(2**top))))

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

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

sum = 0

for i in range(N) : 
    n = i+1
    cnt = 0
    flag = 1
    if n >= K : flag = 0
    
    while(flag == 1) : 
        cnt += 1
        nn = n * (2 ** cnt)
        if(nn >= K) : 
            flag = 0
    
    sum += (1/2) ** cnt
sum = sum * (1/N)

print(sum)

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

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



ans = []
for p in range(1,n[0]+1):
    c = 0
    while p < n[1]:
        p *= 2
        c+=1

    ans.append((1/n[0])*(1/2)**(c+1))


print(sum(ans)*2)

Solution (Python):
import math

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

ans = 0.0
for i in range(1, N+1):
    count = max(0, math.ceil(math.log(K/i, 2)))
    ans += 1/(N * (2 ** count))
print(ans)

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

Solution (Python):
t = input().split()
n, k = int(t[0]), int(t[1])
ans = 1.0
for i in range(1, min(n + 1, k)):
    ki, cp = i, 1.0 / n * 0.5
    while ki < k:
        ki *= 2
        ans -= cp
        cp *= 0.5
print(ans)

Solution (Python):
import math
x, y = [int(i) for i in input().split()]

ans = 0
for i in range(1,x+1):
    if i >= y:
        ans += (1/x)*(x+1-i)
        break
    else:
        t = math.ceil(math.log2(y/i))
        ans += (1/x)*pow(0.5,t)

print(ans)

Solution (Python):
n,k=map(int,input().split())
if n>=k:
    ans=(n-k+1)/n
        
else:
    ans=0.0
for i in range(1,min(n,k)+1):
        tmp=1.0
        while i<k:
            i=i*2
            tmp=tmp*0.5
        if tmp<1:
            ans+=tmp/n
print('{:.17g}'.format(ans))

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

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

Solution (Python):
import bisect
two_ruijo_list = [2**i for i in range(18)]
N,K = map(int,input().split())
if K <= N:
    mi = K
    ans = (N-K+1)/N
else:
    mi = N+1
    ans = 0

for i in range(1,mi):
    d = bisect.bisect_left([two_ruijo_list[j]*i for j in range(18)], K)
    ans += 0.5**d /N
print(ans)

Solution (Python):


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

ans = 0

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

Solution (Python):
import math

def main():
    N, K = map(int, input().split())
    probs = list()
    for i in range(1, N+1):
        p = math.pow(1/2, get_time(i, K))
        probs.append(p)
    p = sum(probs)/N
    print(p)

def get_time(num, goal):
    time = 0
    while(num < goal):
        num *= 2
        time += 1
    return time

if __name__ == "__main__":
    main()

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

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

Solution (Python):
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0.0
for i in range(1,N+1):
    cnt = 0
    while i < K:
        i *= 2
        cnt += 1
    ans += (1/N)*(0.5)**cnt
print(ans)

Solution (Python):
import math

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

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

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

print((1/N) * x)

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

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

ans = 0
log = []
for n in range(1,N+1):
    r = 0
    while n < K:
        n *= 2
        r += 1
    ans += 0.5**(r)
    log.append(r)

    

print(ans/N)

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

ans = 0
for i in range(1, n+1):
    prob = 1/n
    while i < k:
        i *= 2
        prob /= 2
    ans += prob
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:
        tmp = i
        cnt = 0
        while tmp < k:
            tmp *= 2;
            cnt += 1
        ans += (1/n) * (1/2)**cnt

print(ans)

Solution (Python):
N,K=map(int, raw_input().split())
kiso=float(1)/N

ans=0

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

print ans

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

ans = 0

for i in range(1,N+1) :
    pr = (1/N)
    score = i
    
    while score <= K-1 :
        score *= 2
        pr *= 0.5
    
    ans += pr

print(ans)

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

p = 0
v = 1.0/N
for i in range(1,N+1):
  
  if i < K:
    s = i
    c = 0
    while s < K:
      s = s * 2
      
      c += 1
    
    p += v * pow(0.5,c)
  else:
    p += v
    
print(p)

Solution (Python):
from collections import defaultdict, deque, Counter
def inpl(): return list(map(int, input().split()))

N, K = inpl()
ans = 0
X = 17

for i in range(1, N+1):
    while X and i * 2**(X-1) >= K:
        X -= 1
    ans += .5 ** X

print(ans/N)

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

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

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

Solution (Python):
from math import ceil


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


ans = sum(
    1 / (2**((ceil(K / i) - 1).bit_length()))
    for i in range(1, N + 1)
) / N


print(ans)

Solution (Python):
import sys

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

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

            ans += 1 / N * (0.5)**cnt

    return ans


if __name__ == '__main__':
    print(main())

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

prob = 0.0
for i in range(1, n + 1):
    probtmp = 1 / n
    itmp = i
    while k > itmp:
        itmp *= 2
        probtmp /= 2
    prob += probtmp

print(prob)

Solution (Python):
import math

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

m = [2**i for i in range(18)]

sum = 0

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

print(sum/n)

Solution (Python):
import math
n=input().split()
N=int(n[0])
K=int(n[1])
c = 0
for i in range(1,N+1):
    if i < K:
        if math.log2(K/i) % 1 == 0:
            a =int(math.log2(K/i))
            b = (1/2)**a
            c = b + c
        else:
            a =int(math.log2(K/i) + 1)
            b = (1/2)**a
            c = b + c
    if i >= K:
        c = c + 1
c = c/N
print(c)

Solution (Python):
import math

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

    p = 0.0
    for i in range(1, K):
        if i > N:
            break
        m = math.ceil(math.log2(K / i))
        p += 1 / N * 0.5 ** m

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

    print(p)

if __name__ == '__main__':
    main()

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

M = min(N, K)
p = max((N-K)/N, 0)
for n in range(1, M+1):
    p += 2**(-ceil(log2(K/n))) / N
print(p)

Solution (Python):
from math import ceil
res = 0
N, K = map(int, input().split())
for n in range(1, N + 1):
    if n >= K:
        res += 1 / N
        continue
    val = ceil(K / n - 1)
    res += 1 / (2 ** (len(bin(val)) - 2) * N)
print(res)

Solution (Python):
import math 

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

prob=0

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

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

prob = 0

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

print(prob)

Solution (Python):
a,b = map(int, input().split())

ret = 0

for i in range(1,a+1): 
	tmp = 1 / a 
	now = i
	while now < b:
		now *= 2
		tmp /= 2
	ret += tmp


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

Solution (Python):
n,k = (int(i) for i in input().split())
num,x,N,ans,f = 0,[],n,0,1
while f:
    if k==1: f = 0
    if n>=k: x.append((n-k+1,num))
    n,k,num = min(n,k-1),(k+1)//2,num+1
for i,j in x: ans+=(2**(num-j))*i
print(1.0*ans/(N*(2**num)))

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

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

print(ans / n)

Solution (Python):
N, K = map(int, input().split())
i = 0
while (2**i) < K:
    i+= 1

numerator = 0
denominator = 2**i

answer = 0
for x in range(1,N+1):
    i = 0
    while (2**i) * x < K:
        i += 1
    numerator += denominator // (2**i)
    
answer = numerator / (denominator * N)
print(answer)

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

Solution (Python):
import math


import math


def main():
    N, K = map(int, input().split())
    ans = 0
    for i in range(N): 
        tmp = K / (i+1)
        a = math.log2(tmp)
        if a < 0:
            a = 0
        elif not a.is_integer():
            a = int(a) + 1
        '''
        if tmp.is_integer():
            tmp = int(tmp)
            if not (tmp and ):
                a = int(math.log2(tmp))
        else:
            a = int(math.log2(tmp)) + 1
        '''
        ans += 0.5 ** a
    ans /= N

    
    print(ans);


main()

Solution (Python):
import math


import math


def main():
    N, K = map(int, input().split())
    ans = 0
    for i in range(N): 
        tmp = K / (i+1)
        a = math.log2(tmp)
        if a < 0:
            a = 0
        elif not a.is_integer():
            a = int(a) + 1
        '''
        if tmp.is_integer():
            tmp = int(tmp)
            if not (tmp and ):
                a = int(math.log2(tmp))
        else:
            a = int(math.log2(tmp)) + 1
        '''
        ans += 0.5 ** a
    ans /= N

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


main()

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

for i in range(1,n+1):
  flag = False
  if i >= k:
    ans += 1/n
  else:
    while flag == False:
      prob *= 1/2
      i *= 2
      if i >= k:
        ans += prob/n
        flag = True
        prob = 1
print(ans)

Solution (Python):
import math

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

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

print(ans)

Solution (Python):
n, k = map(int, input().split())
p = 0
pp = 1 / n

for i in range(1, n + 1):
    if k < i:
        p += pp
    else:
        c = 0
        b = i
        while b < k:
            b = b * 2
            c += 1
        p += pp * (0.5 ** c)

print(p)

Solution (Python):
def prob(n, k):
    ans = 0
    for i in range(1, n+1):
        now = i
        count = 0
        while (now < k):
            now *= 2
            count += 1
        ans += (0.5) ** count
    return ans / n

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


main()

Solution (Python):
n, k = map(int, input().split())
b = 1.0 / n
ret = 0
while n > 0:
    t = max(n - k + 1, 0)
    ret += b * t
    n -= t
    k -= k // 2
    b *= 0.5
print(ret)

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

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    n, k = LI()
    s = S()
    s[k-1] = s[k-1].lower()
    print("".join(s))

    return


def B():
    s = S()
    a = int("".join(s[:2]))
    b = int("".join(s[2:]))
    if 0 < a <= 12:
        if 0 < b <= 12:
            print("AMBIGUOUS")
        else:
            print("MMYY")
    elif a == 0:
        if 0 < b <= 12:
            print("YYMM")
        else:
            print("NA")
    else:
        if 0 < b <= 12:
            print("YYMM")
        else:
            print("NA")
    return


def C():
    n, k = LI()
    ans = 0
    if k == 1:
        print(1)
        return
    nibuiti = [None for i in range(int(math.log2(k) + 1))]
    for num in range(int(math.log2(k) + 1)):
        if num == 0:
            nibuiti[num] = 1 / 2
            continue
        nibuiti[num] = nibuiti[num-1]/2
        
    for i in range(1, n + 1):
        if i >= k:
            ans += 1
            continue
        b = nibuiti[int(math.log2((k - 1) // i))]
        ans += b
    print(ans/n)
    return


def D():
    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == '__main__':
    C()

Solution (Python):
N,K=map(int,input().split())
ans=0.0
tmp=0
ex=0
for i in range(1,N+1):
  if i>=K:
    ans+=1/N
  else:
    tmp=i
    for a in  range(1,10**5):
      tmp*=2
      if tmp>=K:
        ex=a
        break
    ans+=(1/N)*(1/2)**ex
print(ans)

Solution (Python):
from math import pow

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

    print(ans)

Solution (Python):
from fractions import Fraction


a,b = map(int,input().split(" "))
total = 0

for i in range(1,a+1):
    j = 0
    still = True
    while still:
        if b <= i * (2 ** j):
            still = False
        else:
            j = j+1
    total += Fraction(1,a)*Fraction(1,2 ** j)

print(float(total))

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

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

print(result)

Solution (Python):
import math
N, K = list(map(int, input().split()))
result = 0
for i in range(1, N+1):
  result += (1/N) * 0.5 ** math.ceil(math.log(math.ceil(K/i), 2))
print(result)

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

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

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

min = 0
max = 0
ans = 0
num = 1

while True:
    if 2 ** min >= k / n:
        break
    min += 1

while True:
    if 2 ** max >= k:
        break
    max += 1




for i in range(max,min-1,-1):
    
    count = 0
    while num * 2 ** (i-1) < k or i == 0:
        count += 1
        
        num += 1
        if num > n:
            break
    ans += count / (n * 2 ** i)

print(ans)

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

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

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

g = 0
ps = 0
for i in range(n):
    g = i+1
    m = 0
    while g < k:
        g = g * 2
        m = m + 1
    p = float(0.5**m / n)
    ps = ps + p

print(ps)

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

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

Solution (Python):
import math

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

def f(n):
	global K
	x = math.ceil(math.log(K/n, 2))
	if x < 0:
		x = 0
	if x > K:
		x = K
	return (0.5)**x

print('{:.10f}'.format(sum([f(n) for n in range(1, N+1)])/N))

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

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

Solution (Python):
import math

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

def prob(a, n, k):
    c = math.ceil(math.log(k/a,2))
    return (1/n)*(1/2)**c

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

for i in range(1,min(N,K)+1):
    ans += prob(i, N, K)

print(ans)

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

def ta(m,cnt):
    if k>m:
        cnt+=1
        m*=2
        return ta(m,cnt)
    else:
        return cnt

for i in c:
    cnt=0
    x=(0.5**ta(i,cnt))/n
    ans+=x
print(ans)

Solution (Python):
import numpy as np
N, K = map(int, input().rstrip().split())
pro = 0.
for i in range(1,N+1):
    x = np.log2(K) - np.log2(i)
    x = np.ceil(x)
    if x > 0:
        pro += 1/N*(1/2)**x
    else:
        pro += 1/N
print(pro)

Solution (Python):

N, K = map(int, input().split())
each_slow = []
for i in range(1, N+1): 
    d = i
    cnt = 0
    while (d<K):
        cnt += 1
        d *= 2
    each_slow.append(cnt)


dice = 1/N 
coin = 1/2 

win = [] 
for i in range(1, N+1):
    
    rate = dice * coin ** each_slow[i-1]
    win.append(rate)
    
print(sum(win))

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

Solution (Python):

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

for i in range(1, n+1):
    if i >= k:
        prob += 1/n
    else:
        m = 1
        while i*2**m < k:
            m += 1
        prob += 1/n * (0.5) ** m
        
print(prob)

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

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

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

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

print(tmp)

Solution (Python):

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)

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

Solution (Python):
N, K = [int(nk) for nk in input().split()]
probability = 0
for n in range(N):
    score = n+1
    coin = 1
    while score < K:
        score = score * 2
        coin = coin * (1/2)
    probability += (1/N) * coin
print(probability)

Solution (Python):
from math import log, ceil

N, K = map(int, input().split())
ans = 0
for i in range(1, N + 1):
    percent = (1 / 2)**ceil(log(ceil(K / i), 2))
    ans += percent
print(ans/N)

Solution (Python):
n,k = map(int,input().split())
ans = []
for i in range(1,n+1):
    if i < k:
        tmp = k/i
        counter = 0
        for _ in range(1000000):
            tmp = tmp/2
            if tmp <=1:
                break
            else:
                counter +=1
        ans.append(1/n*(1/2)**(counter+1))
    else:
        ans.append(1/n)
print(sum(ans))

Solution (Python):
import numpy as np
 
N, K = map(int, input().split())
 
def get_x(n, K):
    if n >= K:
        return 0
    else:
        x_raw = np.log2(K) - np.log2(n)
        return np.ceil(x_raw)

def get_prob(n, K):
    x = get_x(n, K)
    if x == 0:
        return 1
    else:
        return (1/2)**x
    
ans = np.mean([get_prob(n, K) for n in range(1, N+1)])
 
print(ans)

Solution (Python):

n, k = list(map(int, input().rstrip().split()))
ans = 0
for i in range(1, n + 1):
    if i >= k:
        ans += 1 / n
    else:
        m = 1
        while i * 2 ** m < k:
            m += 1
        ans += 1 / n * (0.5) ** m
print(ans)

Solution (Python):
import sys

def prob(cur, t):
    if cur >= t: return 1
    return 1.0/2.0 * prob(2*cur, t)

if __name__ == '__main__':
    input = sys.stdin.read()
    N, K = map(int, input.split())
    res = 0
    for i in xrange(1, N+1):
        res += 1.0/N * prob(i, K)
    print res

Solution (Python):
import numpy as np
import math

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


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

else:
    p_e = 0
    for i in range(1, N+1):
        p_i = (1 / N) * ((1 / 2) ** (math.ceil(np.log2(K / i))))
        prob.append(p_i)


s = sum(prob) + p_e
print("{:.12f}".format(s))

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

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

Solution (Python):
from fractions import Fraction
N, K = map(int, input().split())
F = 0

for i in range(1, N + 1):
    point = i
    j = 0
    while point < K:
        point *= 2
        j += 1
    F += float((1/N) * ((1/2) ** j))

print(F)

Solution (Python):
import math
range2 = 17
tables = list(map(lambda x: 2.0 ** (range2-x), range(range2+1)))
 
line = input()
N , K = list(map(int, line.split(' ')))
result = 0
for i in range(N):
    dice = i + 1.0
    if dice >= K:
        result += tables[0]
        continue
    val = math.ceil(math.log2(K / dice))
    result += tables[val]
finalResult = result / N / (2**17)
print('{:.12f}'.format(finalResult))

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

ans = 0
for i in range(1, N+1):
    point = i
    percentage = 1.0
    while point < K:
        point *= 2
        percentage *= 0.5
    ans += percentage

print(ans/N)

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


if __name__ == '__main__':
    main()

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

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

ans /= n

print(ans)

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

Solution (Python):
def f(x,y):
    i=1
    while x<y:
        x*=2
        i*=2
    return 1/i

n,k=map(int,input().split())
q=0
for i in range(1,n+1):
    q+=f(i,k)
print(q/n)

Solution (Python):
def main():
    N, K = map(int, input().split())
    ans = 0
    for n in range(1, N + 1):
        s = n
        c = 0
        while K > s:
            s *= 2
            c += 1
        ans += (1 / N) * (1 / 2) ** c
    print(ans)


main()

Solution (Python):
def main():
    N, K = map(int, input().split())
    ans = 0
    for n in range(1, N + 1):
        s = n
        c = 1
        while K > s:
            s *= 2
            c /= 2
        ans += (1 / N) * c
    print(ans)


main()

Solution (Python):
N,K = input().strip().split(' ')
N,K = [int(N),int(K)]

P = 0.0

for n in range(1,N+1) :
    count = 0
    k = n
    while k < K:
        count += 1
        k = k * 2
    
    P += ( 1 / N * 1/pow(2,count))
    

print(P)

Solution (Python):
import math
a, b=map(int, input().split())
n=s=0
if b<=a:
	n=a-b+1
for i in range(1, min(a+1,b)):
	p=b/i
	p=math.ceil(math.log2(p))
	s+=(1/a)*(0.5**p)
print(s+(n/a))

Solution (Python):
import math

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

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

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

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

print(s / n)

Solution (Python):
print("{0:.15f}".format((lambda n:sum([1/(1<<sum([1 if i*(1<<j)<n[1]else 0 for j in range(20)])) for i in range(1,n[0]+1)])/n[0])(list(map(int,input().split())))))

Solution (Python):
'''input
100000 5
'''
from math import ceil, log2
N, K = [int(x) for x in input().split()]

ats = 0.0

for i in range(1, N+1):
	if i >= K:
		ats += 1/N
		continue

	ats += 1/N/(2.0**(float(ceil(log2(K/i)))))

print(ats)

Solution (Python):


import math
N,K = [int(x) for x in input().split()]
ans = 0
a =[]
for i in range (1,N+1):
    n = math.ceil(math.log2(K/i))
    if n >= 0:
        ans += (1/N) *((1/2)**n)
    else:
        ans += 1/N
    a.append(n)






print(ans)

Solution (Python):
import math
N,K = map(int,input().split())
cnt = 0
for n in range(1,N+1):
    if K/n <= 1:
        x = 0
    elif abs((math.log(K)-math.log(n))//math.log(2)-(math.log(K)-math.log(n))/math.log(2))<=0.00001:
        x = (math.log(K)-math.log(n))//math.log(2)
    else:
        x = (math.log(K)-math.log(n))//math.log(2)+1
    cnt += (0.5)**x

print(cnt/N)

Solution (Python):
import math
N,K = map(int,input().split())
cnt2 = 0
for n in range(1,N+1):
    if K/n <= 1:
        x = 0
    elif abs((math.log(K)-math.log(n))//math.log(2)-(math.log(K)-math.log(n))/math.log(2))<=0.00001:
        x = (math.log(K)-math.log(n))//math.log(2)
    else:
        x = (math.log(K)-math.log(n))//math.log(2)+1
    cnt2 += (0.5)**x
  

print(cnt2/N)

Solution (Python):
n,k=map(int,input().split())
if n>=k:
    a=k-1
else:
    a=n
b=[1/n]*n
for i in range(1,a+1):
    j=i
    while i<k:
        b[j-1]=1/2*b[j-1]
        i=i*2
print(sum(b))

Solution (Python):
import math
import sys
import numpy

N,K = map(int, input().split())
a = 0.000000000
b = 1
for i in range(1,N+1):
    b = 1
    if i >= K:
        a += 1/N
    else :
        tmp = i
        while tmp < K:
            tmp *= 2
            b /= 2
        a += b/N
print(a)

Solution (Python):
import math
import sys
import numpy

N,K = map(int, input().split())
a = 0.000000000
b = 1
for i in range(1,N+1):
    b = 1
    if i >= K:
        a += 1/N
    else :
        tmp = i
        while tmp < K:
            tmp *= 2
            b /= 2
        a += b/N
print(a)

Solution (Python):
import math

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

print(sum([pow(0.5, math.ceil(math.log2(K/a))) if math.log2(K/a) >= 0 else 1 for a in range(1, N+1)])/N)

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

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

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

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) * (1/2) ** math.ceil(math.log(K / i, 2))

print(p)

Solution (Python):
import math
N,K = [int(x) for x in input().split()]
p = 0
for x in range(N):
    k = K/(x+1)
    if x < K:
        k_log = math.ceil(math.log2(k))
    else:
        k_log = 0
    p += 1/N/pow(2,k_log)

print(p)

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