Problem:
 Score : 300 points    Problem Statement Snuke has a fair N -sided die that shows the integers from 1 to N with equal probability and a fair coin. He will play the following game with them:   Throw the die. The current score is the result of the die.  As long as the score is between 1 and K-1 (inclusive), keep flipping the coin. The score is doubled each time the coin lands heads up, and the score becomes 0 if the coin lands tails up.  The game ends when the score becomes 0 or becomes K or above. Snuke wins if the score is K or above, and loses if the score is 0 .   You are given N and K . Find the probability that Snuke wins the game.      Constraints  1 ≤ N ≤ 10^5  1 ≤ K ≤ 10^5  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  K       Output Print the probability that Snuke wins the game. The output is considered correct when the absolute or relative error is at most 10^{-9} .        Sample Input 1 3 10      Sample Output 1 0.145833333333   If the die shows 1 , Snuke needs to get four consecutive heads from four coin flips to obtain a score of 10 or above. The probability of this happening is \frac{1}{3} \times (\frac{1}{2})^4 = \frac{1}{48} .  If the die shows 2 , Snuke needs to get three consecutive heads from three coin flips to obtain a score of 10 or above. The probability of this happening is \frac{1}{3} \times (\frac{1}{2})^3 = \frac{1}{24} .  If the die shows 3 , Snuke needs to get two consecutive heads from two coin flips to obtain a score of 10 or above. The probability of this happening is \frac{1}{3} \times (\frac{1}{2})^2 = \frac{1}{12} .   Thus, the probability that Snuke wins is \frac{1}{48} + \frac{1}{24} + \frac{1}{12} = \frac{7}{48} \simeq 0.1458333333 .       Sample Input 2 100000 5      Sample Output 2 0.999973749998

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

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

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


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

Solution (Python):

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

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

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

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n,k=MI()
probab=0
for i in range(1,n+1):
    s=i
    count=0
    while s<k:
        s*=2
        count+=1
    probab+=1/(2**(count))
print(probab/n)

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

Solution (Python):
import math

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

print(sum(a))

Solution (Python):
import math
a,b = map(int,input().split())
ans = 0
count = 0
dummy2 = 1/a
for i in range(1,a+1):
  while(1):
    if i >= b:
      break
    i *= 2
    count += 1
    
  ans += ((1/2)**count)*dummy2
  count = 0
print(ans)

Solution (Python):
mod = 10 ** 9 + 7
mod2 = 2 ** 61 + 1
from collections import deque
import heapq
from bisect import bisect_left, insort_left, bisect_right

_NUMINT_ALL = list(range(10))


def main():
    ans = solve()
    if ans is not None:
        print(ans)


def solve():
    N, K = iip(False)

    ans = 0

    for i in range(1, N+1):
        cur = 1
        c2 = i
        for j in range(1000):
            if c2 >= K:
                break
            c2 *= 2
            cur /= 2
            
        ans += (1/N) * (cur)

    print(ans)








def iip(listed=True, num_only=True):  
    if num_only:
        ret = [int(i) for i in input().split()]
    else:
        ret = [int(i) if i in _NUMINT_ALL else i for i in input().split()]

    if len(ret) == 1 and not listed:
        return ret[0]
    return ret


def saidai_kouyakusuu(a, b):  
    for i in soinsuu_bunkai(a):
        if b % i == 0:
            b //= i
    return a * b


def sort_tuples(l, index):  
    if isinstance(l, list):
        l.sort(key=lambda x: x[index])
        return l
    else:
        l = list(l)
        return sorted(l, key=lambda x: x[index])


def count_elements(l):  
    d = {}
    for i in l:
        if i in d:
            d[i] += 1
        else:
            d[i] = 1
    return d


def safeget(l, index, default="exception"):  
    if index >= len(l):                      
        if default == "exception":
            raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。配列の長さは", len(l), "です"]))
        else:
            return default
    elif index < 0:
        if default == "exception":
            raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。負の値は許可されていません"]))
        else:
            return default
    else:
        return l[index]


def iipt(l, listed=False, num_only=True):  
    ret = []
    for i in range(l):
        ret.append(iip(listed=listed, num_only=num_only))
    return ret


def sortstr(s):  
    return "".join(sorted(s))


def iip_ord(startcode="a"):  
    if isinstance(startcode, str):
        startcode = ord(startcode)
    return [ord(i) - startcode for i in input()]


def YesNo(s):  
    if s:
        print("Yes")
    else:
        print("No")


def fprint(s):  
    for i in s:
        print(i)


def bitall(N):  
    ret = []
    for i in range(2 ** N):
        a = []
        for j in range(N):
            a.append(i % 2)
            i //= 2
        ret.append(a)
    return ret

def split_print_space(s):  
    print(" ".join([str(i) for i in s]))


def split_print_enter(s):  
    print("\n".join([str(i) for i in s]))


def soinsuu_bunkai(n):  
    ret = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):  
    if n <= 0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r + 1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        
        pass
    return ret


def inv(n, mod):  
    return power(n, mod - 2)


def power(n, p, mod_=mod):  
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p // 2, mod_) ** 2) % mod_
    if p % 2 == 1:
        return (n * power(n, p - 1, mod_)) % mod_


if __name__ == "__main__":
    main()

Solution (Python):
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

n, k = load_list()

p = 0
for i in range(1, n+1):
    if i >= k:
        p += 1 / n
        continue
    m = math.ceil(math.log2(k) - math.log2(i))
    p += 1 / n * ((1/2) ** m)

print(p)

Solution (Python):


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

ret = 0

for i in range(1, n+1):
    tmp = 1.0 / n
    now = i
    while now < k:
        now *= 2
        tmp /= 2
    ret += tmp

print(ret)

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

A = 0
for i in range(N):
  j = 0
  while True:
   if K / (i+1) / 2**j <= 1:
    break
   else:
    j+=1
  A += 1/N * (0.5)**j

print(A)

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

Solution (Python):
import math
N,K = map(int,input().split())
ans = 0.0
def f(i):
    k=float(K/i)
    x=0
    while(k>1):
        k /=2
        x+=1
    
    return x

for i in range(1,N+1):
    ans += 1.0/float(float(N)*float(2.0**f(i)))
print(ans)

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

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

Solution (Python):
import math

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

N, K = get_ints()
probs = [0] * max(K + 1, N + 1)
A = len(probs)

for i in range(A - 1, 0, -1):
    if i >= K:
        probs[i] = 1
    elif i * 2 >= K:
        probs[i] = 1 / 2
    else:
        probs[i] = probs[i * 2] / 2

ans = 0
for i in range(1, N + 1):
    ans += probs[i]


ans /= N
print(ans)

Solution (Python):

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

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    N, K = input_nums()
    total_p = 0
    for i in range(1, N+1):
        p = 1/N
        val = i
        cnt = 0
        while val < K:
            cnt += 1
            val *= 2
        total_p += p * (1/2)**cnt
    print(total_p)

if __name__ == '__main__':
    main()

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

ks = [k00]
ns = [0]
k0 = k00+0
n0 = 0
while k0 >1:
    k0 = ((k0*-1)//2)*-1
    n0 += 1
    ks.append(k0)
    ns.append(n0)

for i,j in enumerate(ks):
    if n == j:
        ks1 = [1]
        for k,l in enumerate(ks[i:][:-1]):
            ks1.append(ks[i:][k] - ks[i:][k+1])
        ns1 = ns[i:]
        break
    elif n > j:
        ks1 = [n-j+1]
        for k,l in enumerate(ks[i:][:-1]):
            ks1.append(ks[i:][k] - ks[i:][k+1])
        ns1 = ns[i:]
        break

ans = 0
b1 = 1/n
for i,j in enumerate(ks1):
        ans += (ks1[i])*((1/2)**ns1[i])*(1/n)

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

Solution (Python):
def after_explanation():
    n, k = map(int, input().split(' '))
    result = 0
    for i in range(1,n+1):
        count = 0
        while i < k:
            count += 1
            i *= 2
        result += 1.0/2**count/n
    print(result)

after_explanation()

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

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

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

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

  while point < K:
    point *= 2
    count += 1
  
  result += (1/N) * pow(0.5, count)

print(result)

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

ret = 0

for i in range(n):
    me = i + 1
    prob = 1
    while me < k:
        prob /= 2
        me *= 2
    ret += (prob / n)

print(ret)

Solution (Python):
from math import log2, ceil

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

p = 0
for n in range(1, N + 1):
    if n > K:
        p += 1 / N
        continue
    x = ceil(log2(K) - log2(n))
    
    p += 1 / N * pow(0.5, x)
print(p)

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

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

print(ans)

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

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

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

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

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

print(ans)

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

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

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

prob = 0.0
for p in range(1, N+1):
    c_prob = 1/N
    while p <= K-1:
        p *= 2
        c_prob *= 1/2
    prob += c_prob

print(prob)

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

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

print(ans)

Solution (Python):
import sys
import math

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

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

ans = 0

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


rate = 0
for i in range(1,L+1,1):
    
    score = i
    c = 0
    
    while score < K:
        score = score * 2
        c += 1
    r = 2** c
    
    rate += 1/r
    
    
ans += (1/N) * rate

print(ans)

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

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

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

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

print(a)

Solution (Python):
import math
n,k=map(int,input().split())
now=k
cnt=0 
ans=max(0,n-k+1)
while now>=1:
    a=now/2
    b=math.ceil(a) 
    if now!=int(now):
        c=int(now) 
    else:
        c=int(now)-1
    cnt+=1
    if b>min(k-1,n): 
        now=a
        continue
    elif c>min(k-1,n): 
        c=min(k-1,n) 
    ans+=1/(2**cnt)*(c-b+1)
    now=a
    if now==1:
        break
print(ans/n)

Solution (Python):
c=0
def doublet(n,f):
    global c
    if n<f:
        c=c+1
        return doublet(2*n,f)
    else:
        return c
num,k=input().split()
num=int(num)
k=int(k)

if (num>=1 and num<=10**5) and (k>=1 and k<=10**5):
    sum_power=0.0
    for i in range(1,(num+1),1):
        count=doublet(i,k)
        p=pow(2,count)*num
        sum_power=sum_power+(1/p)
        c=0
    print(sum_power)

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

Solution (Python):
import math
n,k = map(int,input().split())
sumlist = []
for i in range(1,n+1):
  point = i
  if point <= k-1:
    s = math.log(k/i,2)
    if s == int(s):
      sumlist.append((1/2)**(int(s)))
    else:
      sumlist.append((1/2)**(int(s)+1))
  else:sumlist.append(1)
print(round(sum(sumlist)/n,10)-10**(-10))

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

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 * (0.5)**cnt
print(ans)

Solution (Python):
n, k = map(int, input().split())
ans = 0
i=0
pre = 0
tmp = 0
if n >= k:
    ans += (n-k+1)
    pre = k
    i = 1
    tmp = (pre+1)//2
else:
    pre = n+1
    tmp = k
    i=0
    while n < tmp:
        tmp = (tmp+1)//2
        i+=1
    ans += (pre-tmp)*((0.5)**i)
    pre = tmp
    i+=1
    tmp = (pre+1)//2
while pre != tmp:
    
    ans += (pre-tmp)*((0.5)**i)
    pre = tmp 
    i+=1
    tmp = (pre+1)//2
print(ans/n)

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

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate
    
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    

    
    

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


if __name__ == '__main__':
    main()

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

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

for i in range(1,N+1):
    p=1
    sc=i
    cnt=0
    while 1<=sc<=K-1:
        cnt +=1
        p /=2
        sc *=2
    
    ans += p/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
  p = N * pow(2,cnt)
  ans += 1 / p
  
print(ans)

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

for i in range(1,n+1):
    score = i
    rate = 1/n
    while(score <= k-1):
        rate *= (1/2)
        score  *= 2
    rate_total.append(rate)

print(sum(rate_total))

Solution (Python):
N, K = map(int, input().split())
L = [0]*N
for i in range(min(K-1,N)):
  n = 1
  while (i+1)*(2**n) < K:
    n = n+1


  L[i] = (1/2)** n

if N >= K:
  for j in range(K-1,N):
    L[j] = 1

print(sum(L)/N)

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

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

Solution (Python):
N, K =map(int, input().split())
win = 1
cnt = 0
 
def DFS(i, win):
    if(i < K):  
        win *= 0.5 
        i *= 2 
        return DFS(i, win) 
    else:
        return win
    
for i in range(1, N+1): 
    cnt += DFS(i, 1/N)
print(cnt)

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

def DFS(i, win):
    if(i < K):
        win *= 0.5
        i *= 2
        return DFS(i, win)
    else:
        return win
    
for i in range(1, N+1):
    cnt += DFS(i, 1/N)
print(cnt)

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

Solution (Python):
import math

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

prob=0
for dice_num in range(1, N+1):
    if K>dice_num:
        pwr=math.ceil(math.log2(K/dice_num))
        prob+=(1/2)**pwr/N
    else:
        prob+=1/N
print(prob)

Solution (Python):
import numpy as np
import math

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

ans = 0
for i in range(n):
    if k <= i+1:
        ans += (1/n)
    else:
        tmp = math.ceil(np.log2(k/(i+1)))
        
        ans += (1/n) * (1/2)**tmp

print(ans)

Solution (Python):
import numpy as np
import math
N, K = map(int, raw_input().split())

ans = 0
for i in range(1, N+1):

    mi = np.log2(1.0*K/i)

    mi = max(mi,0)
    mi = math.ceil(mi)
    ans += (1.0/2)**mi

ans = ans/N
print ans

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

point=0
ans=0
toss_cnt=0

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

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

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

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

Solution (Python):
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

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

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

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  n, k = input_list()
  ans = 0
  for i in range(1, n+1):
    t = 1.0
    while i < k:
      i *= 2
      t /= 2
    ans += t
  print(ans/n)
  
import math
import fractions
import collections
import itertools
from functools import reduce
main()

Solution (Python):
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()
    ret = 0
    for n in range(1, N+1):
        t = 1
        while n * t < K:
            t *= 2
        ret += 1 / t

    print(ret / N)


if __name__ == '__main__':
    main()

Solution (Python):

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

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

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

Solution (Python):
import math

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

    res = 0
    for i in range(n):
        ini = i + 1
        succ_req = math.ceil(math.log2(math.ceil(k / ini)))
        prob = (0.5 ** succ_req) / n
        res += prob
    print(res)

if __name__ == '__main__':
    main()

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

Solution (Python):
def solve():
    N, M = map(int, input().split())
    l = []
    for i in range(1, N+1):
        a = i
        c = 0
        while a < M:
            a *= 2 
            c += 1
        b = 1 if c == 0 else (0.5)**c
        l.append(b * (1/N))
    return sum(l)

print(solve())

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

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

print(p)

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

N, K = MAP()


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

print(prob)

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

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

print(ans)

Solution (Python):












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

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

print(ans)

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

for i in range(1, n+1):
    score = i
    cnt = 0
    while score < k:
        score *= 2
        cnt += 1
    if cnt==0:
        proba = 1.0
    else:
        proba = (1/2)**cnt
    p[i-1] = proba

ans = 0
for pp in p:
    ans += (1/n)*pp

print(ans)

Solution (Python):
import math

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

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

print(p/N)

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

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

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

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

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

Solution (Python):
import sys
from itertools import combinations, permutations, product, combinations_with_replacement, accumulate
from heapq import heapify, heappop, heappush, heappushpop
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from math import sqrt, log, floor, ceil, factorial, cos, sin, pi 
from fractions import gcd
from operator import mul
from functools import reduce
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
LINF = 2**63-1
NIL = -LINF
MOD = 10**9+7
MGN = 4
def AST(exp: bool, msg: str = ""): assert exp, msg
def TAST(exp: bool, msg = ""):
    if exp is False: print("TAssertionError:", msg)
    while exp is False:
        pass
def EPR(msg): print(msg, file=sys.stderr)
def II(): return int(input())
def IF(): return float(input())
def IS(): return input().replace('\n', '')
def ILCI(n: int): return [II() for _ in range(n)]
def ILCF(n: int): return [IF() for _ in range(n)]
def ILI(): return list(map(int, input().split()))
def ILLI(n: int): return [[int(j) for j in input().split()] for i in range(n)]
def ILF(): return list(map(float, input().split()))
def ILLF(n: int): return [[float(j) for j in input().split()] for i in range(n)]
def LTOS(lst: list, sep: str = ' '): return sep.join(map(str, lst))
def DEC(lst: list): return list(map(lambda x: x-1, lst))
def INC(lst: list): return list(map(lambda x: x+1, lst))


def main():
    N, K = ILI()

    ans = 0.0
    for i in range(1,N+1):  
        scr = i  
        pb = 1.0  
        win = True  
        while True:
            if K <= scr:  
                break
            elif 0 < scr < K:
                scr *= 2
                pb *= 0.5
            else:  
                TAST(False, "ここには来ない")
                scr = 0
                win = False
                break
        if win:
            ans += pb / N

    print("{:.12}".format(ans))


if __name__ == '__main__':
    main()