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

Solution (Python):
import math

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


score = 0
times = []
for i in range(1, min(n + 1, k)):
    times.append(math.ceil(math.log2((k / i))))

if len(times):
    bottom_max = times[0]
    for t in times:
        score += 2 ** (bottom_max - t)
    score /= 2 ** (bottom_max) * n


big = [i for i in range(k, max(k, n + 1))]
score += len(big) / n
print('{:.10f}'.format(score))

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

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

print(ans)

Solution (Python):
import math

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

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

print(probability)

Solution (Python):
import math
s = input().split()
n=int(s[0])
k=int(s[1])
ans=0
for i in range(1,n+1):
    a=math.log2(k/i)
    if a<0:
        a=0
    a=math.ceil(a)
    ans+=(1/n)*(1/2)**a

print(ans)

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

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

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

Solution (Python):
n,k=map(int,input().split())
cnt=0
j=17
for i in range(1,n+1):
    if i>=k:
        cnt+=1
    else:
        while i*(2**j)>=k:
            j-=1
        cnt+=1/2**(j+1)
print(format(cnt/n,'.12f'))

Solution (Python):
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

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

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


if __name__=="__main__":
    main()

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

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

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

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

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

print(win)

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

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()

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

    print(ans)

if __name__ == '__main__':
    resolve()

Solution (Python):
from fractions import Fraction
N, K = map(int, input().split())
ans = 0
for i in range(N):
    s = i + 1
    p = Fraction(1, N)
    while s < K:
        s *= 2
        p *= Fraction(1, 2)
    ans += p
print(float(ans))

Solution (Python):
from decimal import Decimal, getcontext
getcontext().prec = 20
N, K = map(int, input().split())
res = 0
for p in range(1,N+1):
    cnt = 0
    q = 1
    while p*q <K:
        cnt += 1
        q *= 2
    res += Decimal(pow(1/2,cnt))
print(res/N)

Solution (Python):

import sys 
input = sys.stdin.readline

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

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

print(ans)

Solution (Python):

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



ans = 0

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

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

Solution (Python):
n,k = 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/n
print(ans)

Solution (Python):
from math import ceil, log2

n, k = map(int, input().split())
ans = sum(1 / 2 ** ceil(log2(k / i)) for i in range(1, min(n, k) + 1))
print((ans + max(0, n - k)) / n)

Solution (Python):
from math import ceil
from math import log2

n, k = map(int, input().split())
ans = sum(1 / 2 ** ceil(log2(k / i)) for i in range(1, min(n, k) + 1))
print((ans + max(0, n - k)) / n)

Solution (Python):
import math
import time

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

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

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

win = []

for i in range(1, n+1):
  if i >= k:
    win.append(1/n)
  else:
    t = True
    count = 0
    while t == True:
      if i < k:
        i = 2*i
        count += 1
      else:
        t = False
    win.append((((1/2)**count)*(min(n,k)/n))/min(n,k))

total = int(sum(win)*(10**12))/(10**12)
print(total)

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

Solution (Python):
import math

N, K = list(map(lambda k: int(k), input().split(" ")))






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

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

p = 0
for i in range(1, N + 1):
    m = numpy.log2(K / i)
    
    if m < 0:
        m = 0
        
    p += 0.5 ** numpy.ceil(m)
    
print(p / N)

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

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

Solution (Python):
def kaisu(n,k):
  if n>=K:
    return k
  else:
    return kaisu(2*n,k+1)
N,K=map(int,input().split())
ans=0
for i in range(1,N+1):
  ans+=pow(2,20-kaisu(i,0))
ans=ans/(pow(2,20))
print(ans/N)

Solution (Python):
import sys

input = sys.stdin.readline


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

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

    ans /= N
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):








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

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

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

ans = 0.0

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

    ans += 1 / 2 ** t
    
print(ans / N)

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

p = 0

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

print(p)

Solution (Python):
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, k = inintm()

ans = 0

for i in range(1,n+1):
    b = 0
    for _ in range(1,18):
        if i >= k:
            break
        i *= 2
        b += 1
    ans += (1/n)*(0.5**b)

print(ans)

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

Solution (Python):
N, K = list(map(int,input().rstrip().split()))
ans = 0
for i in range(1,N+1):
    p = 1/N
    if i<K:
        while i<K:
            i *= 2
            p *= 0.5
    ans += p
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()))

def main():
    mod=10**9+7
    N,K=MI()
    ans=0
    for i in range(1,N+1):
        temp=1/N
        score=i
        while score<K:
            score*=2
            temp/=2
        ans+=temp
        
    print(ans)
    

main()

Solution (Python):
from math import ceil

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

bef = n + 1
ans = 0
div = 1
while k > 0.5:
    a = ceil(k)
    cnt = max(0, bef - a)
    ans += cnt * div
    div /= 2
    k /= 2
    bef = min(n + 1, a)
print(ans / n)

Solution (Python):

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

    
print(Current_Per)

Solution (Python):
a,b=map(int,input().split())
r = 0
for i in range(1,a+1):
  tmp=1/a
  now=i
  while(now<b):
    now*=2
    tmp/=2
    
  r+=tmp;
print(r)

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+=0.5**math.ceil(math.log2(k/i))/n
print(ans)

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

Solution (Python):
import math

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

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

print(p)

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

ans = 0

def calc(x, goal):
    res = 0
    while x < goal:
        x *= 2
        res += 1
    return res    


for i in range(1, N+1):
    cnt = calc(i, K)
    ans += 1 / N * ((1 / 2) ** cnt)

print(ans)

Solution (Python):
from decimal import Decimal as d 
n,k=map(int,input().split())
ans=d(0)
for i in range(1,n+1):
    x=d(1)
    if i>=k:
        ans+=d(x)
    else:
        while i<k:
            x=d(x)/d(2)
            i*=2
        ans+=x
print(d(ans)/d(n))

Solution (Python):
import math

N,K=map(int,input().split())
p=math.ceil(math.log(K,2))

x=N*(2**p)

s=0

for n in range(1,N+1):
    if n>=K:
        s+=(x//N)
    else:
        q=math.ceil(math.log(K/n,2))
        s+=2**(p-q)
        

print(s/x)

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

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

    sum +=  (1/N)*((1/2)**cnt)
    
    
print(sum)

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

from math import ceil
cnt = 0
for i in range(1,N+1):
    a = ceil(K/i)
    if bin(a).count("1") == 1:
        b = a.bit_length()-1
    else:
        b = a.bit_length()
    cnt += (1/N)*(0.5**b)
print(cnt)

Solution (Python):
n,k=map(int,input().split())
d=[2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]

coin=[]
for i in range(1,n+1):
  if i>=k:
    coin.append(1)
    continue
  for j in range(19):
    if i*d[j] >= k:
      coin.append(0.5**(j+1))
      break
print(sum(coin)/n)

Solution (Python):
from collections import Counter

n,k=list(map(int,input().split()))
enum=0
denom=2**20

for pip in range(1,n+1):
    cnt=0
    score=pip
    while score<k:
        score*=2
        cnt+=1
    
    enum+=2**(20-cnt)

print(enum/denom/n)

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

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

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
    if c!=0:
        p+=((1/2)**c)*(1/N)
if N>=K:
    p+=(N-K+1)/N
print(p)

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

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

print(pn/n)

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

def f(x,y):
  cnt = 0
  while x > y:
    y = y << 1
    cnt +=1
  return cnt

ans = 0
for i in range(1,n+1):
  i2 = bin(i)
  cnt = f(k,i)
  ans += 0.5**cnt

print(ans/n)

Solution (Python):
from decimal import Decimal 
n, k = map(int, input().split())
count = 0
p = 0

if n >= k:
    a = n
    p += Decimal((a - k + 1) / a)
    n = k
    for i in range(k, 1, -1):
        n = n / i * (i - 1)
        while n < k:
            n *= 2
            count += 1
        p += Decimal(1 / a * (1 / 2) ** count)
    print(p)
else:
    a = n

    while n < k:
        n *= 2
        count += 1
    p += Decimal(1 / a * (1/2) ** count)

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

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


if __name__ == "__main__":
    main()

Solution (Python):
def main():
    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 True:
                tmp *= 2
                cnt += 1
                if tmp >= K:
                    break
            ans += 1 / N * (1 / 2)**cnt
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
def get_exp(i,m):
    c=0
    while i<m:
        i=i*2
        c+=1
    return c

n,k=map(int,input().split())
r=0
for x in range(1,n+1):
    r+=1/(n*(2**get_exp(x,k)))
    
print(r)

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

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

print(ans/n)

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

Solution (Python):
import sys
from math import ceil, log2

stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


n, k = nm()
p = 0
for i in range(1, n + 1):
    if i >= k:
        p += 1 / n
    else:
        num = ceil(log2(k / i))
        p += (1 / n) * (1 / pow(2, num))

print(p)

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

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

print(ans)

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

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

print(result)

Solution (Python):
import math
from decimal import Decimal
n,k=map(int,input().split())
a=[0]*(n+1)
for x in range(1,n+1):
  a[x] = max(0, math.ceil(math.log(k,2)- math.log(x,2)))
bunsi = 0
for x in range(1,n+1):
  bunsi += 2**(a[1]-a[x])
print(Decimal(bunsi/(n*2**a[1])))

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

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

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

dice_num = 1

def get_prob(dice_num,k):
    i = 0
    while True:
        i += 1
        if i ==1:
            score = dice_num
        else:
            score *= 2
        if score >= k:
            prob = (1/2)**(i-1)
            break
    return prob

prob_all = 0
for i in range(n):
    prob_all += (get_prob(i+1,k))*(1/n)

print(prob_all)

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

if __name__ == "__main__":
    main()

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

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

for i in l:
    ans += 1/n * (1/2)**i
print(ans)

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

Solution (Python):
a = [int(s) for s in input().split()]
N, K = a[0], a[1]
prob = 0
if N > K - 1: prob += (N - K + 1)/N
prob2 = 0
for i in range(1, min(N, K - 1) + 1):
    a = i
    j = 0
    while(a < K): 
        a = a << 1
        j += 1
    prob2 += 1/(2**j)
print(prob + prob2 * (1/N))

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

res = 0
pi = 1 / n
for i in range(1, n + 1):
    i = k / i
    i = math.log2(i)
    if i <= 0:
        index = 0
    elif int(i) == i:
        index = int(i)
    else:
        index = int(i) + 1
    res += pi / (2 ** index)

print(res)

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

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

ans = 0
for i in range(1, N+1):
    tmp = 0
    check = i
    for j in range(1, 100):
        if check >= K:
            ans += 1 / (N * 2 ** tmp)
            break
        tmp += 1
        check *= 2

print(ans)

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

Solution (Python):
import sys
import math
ans = 0
N,K = map(int,input().split())
for n in range(1,N+1):
    num = max(0, math.ceil(math.log2(K/n)))
    ans += (1/2)**num

print(ans/N)

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

Solution (Python):
import math

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

print(ans/n)

Solution (Python):
import math





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

ans = 0
for i in range(1, N + 1):
  if i < K:
    tt = math.log2(K/i)
    if tt % 1 == 0:
      time = int(tt)
    else:
      time = int(tt) + 1
    ans += (1 / N) * ((1 / 2) ** time)
  else:
    ans += (1/ N)

  
print(ans)

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

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

ans=0

baisuu=1
multiplier=0
count=[0]
for i in range(N,0,-1):
    while baisuu*i<K:
        baisuu*=2
        multiplier+=1
        count.append(0)
    
    count[multiplier]+=1

ans=0
for i in range(len(count)):
    ans+=count[i]*0.5**i

ans/=N
print(ans)

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

for i in range(1, n+1):
    if i<k:
        for j in range(1, 18):
            if i*(2**j) >= k:
                e = j
                break
    else:
        e = 0

    ans += (1/n)*(2**(-e))

print(ans)

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

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

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

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

Solution (Python):
from math import log2

N,K = [int(i) for i in input().split()]
prob = 0
for i in range(1,N+1):
    j = 0
    while 2**(j) * i < K:
        j += 1
    prob += (1/N) * (0.5)**j
    
print(prob)

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

Solution (Python):
import sys
from fractions import Fraction

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N, K = LI()


kakuritu = []
for i in range(1,N+1):
    count = 0
    while i < K:
        i *= 2
        count += 1
    kakuritu.append(N*(2**count))
result = 0
for kaku in kakuritu:
    result += Fraction(1, kaku)


print(result.numerator / result.denominator)

Solution (Python):
n, k = map(int, input().split())
a = {}
p = 0
for i in range(n, 0, -1):
    b = 0
    j = i
    while j < k:
        if j in a:
            b += a[j]
            break;
        else:
            j *= 2
            b += 1
    a[i] = b
c = [0]*20
for i in range(n):
    c[a[i+1]] += 1
for i in range(20):
    p += c[i]*(1/2)**i
print(p/n)

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

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

print(a)

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

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

print(a)

Solution (Python):
from math import log2,ceil
n,k=[int(s) for s in input().split()]

sum=0
for t in range(1,n+1):
    if t>=k:
        sum+=1
    else:
        sum+=1/(2**ceil(log2(k/t)))
print(sum/n)

Solution (Python):

import os
import sys
from io import BytesIO, IOBase




BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")


class union_find:
    def __init__(self, n):
        self.n = n
        self.rank = [0]*n
        self.parent = [int(j) for j in range(n)]
    
    def union(self,i,j):
        i = self.find(i)
        j = self.find(j)
        if self.rank[i] == self.rank[j]:
            self.parent[i] = j
            self.rank[j] += 1

        elif self.rank[i] > self.rank[j]:
            self.parent[j] = i
        else:
            self.parent[i] = j

    def find(self, i):
        temp = i
        if self.parent[temp] != temp:
            self.parent[temp] = self.find(self.parent[temp])
        return self.parent[temp]
from math import log2, ceil
def main():

    n,k = [int(j) for j in input().split()]
    a = max(n-k+1, 0)
    for x in range(1, min(k, n+1)):
        tmp = (1/2)**ceil(log2(k/x))
        
        a+=tmp
    print(a/n)
    
    

    
    
        





        
                
            
        


        
        




        




if __name__ == "__main__":
    main()

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):
import math
N, K = map(int, input().split())
p = [0] * N
for i in range(N):
    n = i + 1
    x = 1 / N
    while n < K:
        x *= 0.5
        n *= 2
    p[i] = x
ans = math.fsum(p)
print(ans)

Solution (Python):
import sys
from math import log2
from math import ceil

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n, k = MI()
    p = 0
    for i in range(1, min(n+1, k)):
        x = ceil(log2(k/i))
        p += 0.5**x
    p += max(0, n-k+1)
    p /= n
    print(p)

if __name__ == '__main__':
    main()

Solution (Python):

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

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

print(cnt / N)

Solution (Python):
import math
n, k = map(int, input().split())
s = 0
for p in range(1, n+1):
    if k > p:
        m = math.ceil(math.log2(-(-k//p)))
        s += 0.5**m
    else:
        s += 1

print(s/n)

Solution (Python):
from math import log2,ceil

N,K=map(int,input().split())
SUM=0
for i in range(1,N+1):
  if i<K:
    n_trial = ceil(log2(K/i))
    tmp = 1/(2**n_trial)
  else:
    tmp = 1
  SUM += tmp
print(SUM/N)

Solution (Python):

import math
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    N, K = MI()
    ans = 0
    for n in range(1, N + 1):
        k = math.ceil(math.log2(K / n))
        ans += (1 / N) * min((1 / 2) ** k, 1)

    print(ans)


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

print(ans)

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

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

ans = 0
for r in range(1, min(K, N+1)):
    x = math.ceil( math.log2(K/r))
    ans += pow(0.5, x) / N
    
if K <= N:
    ans += (N - K + 1) / N
print(ans)

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

ans = []
n_2 = 1 / n
for i in range(1,n+1):
    c = 0
    while i < k:
        c += 1
        i *= 2
    ans.append(n_2*(0.5**c))

print(sum(ans))

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

Solution (Python):
from fractions import Fraction
n,k=map(int,input().split())
times=[0]*n
for i in range(1,n+1):
    count=0
    j=1
    while True:
        if j*i<k:
            count+=1
            j=2*j
        else:
            break
    times[i-1]+=count
ans=0
for k in times:
    ans+=(Fraction(1,2))**k
print(ans.numerator/(ans.denominator*n))

Solution (Python):
from fractions import Fraction
n,k=map(int,input().split())
times=[0]*n
for i in range(1,n+1):
    count=0
    j=1
    while True:
        if j*i<k:
            count+=1
            j=2*j
        else:
            break
    times[i-1]+=count
ans=0
for k in times:
    ans+=(Fraction(1,2))**k
print(ans.numerator/(ans.denominator*n))

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