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

preans = 0
j = 1

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

ans = preans / n

print(ans)

Solution (Python):

import sys
import math

def timesNeed(S0, K):
    return int(math.ceil(math.log2(K)-math.log2(S0)))

def solve(N: int, K: int):
    fact = 1./N
    p = 0.
    for S0 in range(1, min(N, K-1)+1):
        p += math.pow(0.5, timesNeed(S0, K))
    p *= fact
    p += max(0., (N-K+1)/N)
    print(p)
    return

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

if __name__ == '__main__':
    main()

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

sum = 0
for i in range(1,n+1):
    tmp = 1/n
    score = i
    while(score <= k-1 and score >= 1):
        score *= 2
        tmp *= 0.5
    sum += tmp
print(sum)

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

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

answer = sum(map(lambda x: 0.5 ** ceil(log2(k / x)) if x < k else 1, range(1, n + 1))) / n
print(answer)

Solution (Python):
n,k = map(int, input().split())
ttl = 0
res = []
for i in range(1,n+1):
  ttl = i
  cnt = 0
  while True:
    if ttl >= k:
      break
    ttl = ttl*2
    cnt+=1
  p = 0.5**cnt
  res.append(p)
ans = sum(res)/n
print(float(ans))

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

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

Solution (Python):
import math
nk=list(map(int,input().split()))
a=0
for i in range(1,nk[0]+1):
    if i>=nk[1]:
        a+=1
    else:
        p=math.ceil(math.log(nk[1]/i, 2))
        a+=1/(2**(p))
print(a/nk[0])

Solution (Python):
N, K = list(map(int, input().split()))
pro = 0.0
for i in range(1, N + 1):
    mul = i
    count = 0
    while mul < K:
        mul *= 2
        count += 1
    pro += (1 / N) * ((1 / 2) ** count)
print('{:.10f}'.format(pro))

Solution (Python):
import math

N, K = map(int, input().split())
ans = 0
l = [2**i for i in range(18)]

for j in range(1, N+1):
    for k in l:
        if j*k >= K:
            ans += (1/N)*0.5**math.log2(k)
            break
print(ans)

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

ans = 0

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

print(ans)

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

j = 0

while k > 2 ** j:
    j += 1

jl = [j]

for i in range(2, n+1):
    p = jl[i - 2]
    if k <= i:
        p = 0
    else:
        while True:
            p -= 1
            if k > i * (2**p):
                p += 1
                break
    jl.append(p)

ans = 0

for j in jl:
    ans += 2**(-j) / n


print(ans)

Solution (Python):
import math

n, k = map(int, input().split())
nums = [k]
while True:
    a = math.ceil(nums[-1] / 2)
    nums.append(a)
    if a == 1:
        break

max_e = len(nums) - 1
m = n
res = 0
for i, a in enumerate(nums):
    if m >= a:
        res += (m - a + 1) * 2**(max_e - i)
        m = a - 1
print(res / (n * 2**max_e))

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

acc = 0
for dice in range(1, n+1):
    score = dice
    coin_count = 0
    while score < k:
        score *= 2
        coin_count += 1
    acc += 0.5 ** coin_count / n

print(acc)

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

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

    print(ans)


main()

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

import math
sums = 0
for i in range(1,N+1):
    num=int(math.log(K/i,2)+1)
    
    if i>K-1:
        sums +=(1/N)
    else:
        if i*2**(num)>=K>i*2**(num-1):
            sums += 1/(N * math.pow(2,num))
        else:
            sums += 1/(N * math.pow(2,num-1))

print(sums)

Solution (Python):
def calc_log2(x, y, cnt):
    if x >= y: return cnt
    return calc_log2(x * 2, y, cnt + 1)

def calc_power(num, acc):
    if num == 0: return acc
    else: return calc_power(num - 1, acc * 2)

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

max_log2 = calc_log2(1, k, 0)

li = [0] * n
molecure = 0
for i in range(n):
    molecure += calc_power(max_log2 - calc_log2(i + 1, k, 0), 1)

denominator = n * calc_power(max_log2, 1)

print(float(molecure) / denominator)

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

ans=0

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

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

Solution (Python):
N, K = map(int,input().split())
ans = 0
if K <= N:
    ans += (1/N)*(N-K+1)
    dp = [0] + [1/N] * K
else:
    dp = [0] + [1/N] * N + [0] * (K-N)
for i in range(1,K):
    if i % 2 == 0:
        dp[i] += dp[i//2] * (1/2)
if K % 2 == 0:
    ans += sum(dp[K//2:K])*(1/2)
else:
    ans += sum(dp[K//2+1:K])*(1/2)
print(ans)

Solution (Python):
def coin(i,k):
    count = 0
    while i < k:
        i = i * 2
        count += 1
    return count
 
n, k = map(int, input().split())
sum = 0
coin_count = 0
 
 
for i in range(1,n+1):
    x = coin(i, k)
    sum += (1/n) * ((0.5) ** x)
 
print(sum)

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

print(ans)

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

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

def cul(K, n):
    i = 0
    while n < K:
        n = n*2
        i += 1
    return 1/(2**i)

ans = 0
for n in range(1, N+1):
    ans += (1/N) * cul(K, n)

print(ans)

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

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

Solution (Python):
def nankai(Me):
    cnt = 0
    for j in range(20):
        if K-1 >= Me*(2**j):
            cnt +=1
        else: break
    return cnt

      
N, K = map(int,input().split())
P=[(1/N)*(1/2)**nankai(i) for i in range(1,N+1)]
print(sum(P))

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



p=0
for i in range(1,n+1):
    if k//i==0:
        p+=1/n
    elif k%i!=0:
        p+=((1/2)**(int(math.log2(k//i)+1)))/n
    elif 2**int(math.log2(k//i))!=k//i:
        p+=((1/2)**(int(math.log2(k//i)+1)))/n
    else:
        p+=((1/2)**(int(math.log2(k//i))))/n

print(p)

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 += 0.5**cnt
    
print(ans/N)

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

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

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

ans = 0
ite = 0
for i in range(1, N+1):
    for j in range(10**5):
        if K <= i*2**j:
            ite = j
            break

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

print(ans)

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

for i in range(18):
    d[i] = 0
l = [2**i for i in range(18)]

for i in range(1,n+1):
    kk = i
    c = 0
    while(kk < k):
        c += 1
        kk *= 2
    else:
        d[c] += 1
else:
    for ind,val in d.items():
        ans += val*((1/2)**ind)
    
    print(ans/n)

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

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

base = 1 / n
ans = 0
for i in range(1, n+1):
    if i >= k:
        ans += base
        continue

    cnt = 0
    while 1:
        i *= 2
        cnt += 1
        if i >= k:
            break

    ans += base * pow(0.5, cnt)

print(ans)

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

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

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

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

max_t = int(ceil(log2(K)))

cnt = 0
for n in range(1, N + 1):
    t = max(int(ceil(log2(K / n))), 0)
    cnt += 2 ** (max_t - t)

print (cnt / 2 ** max_t / N)

Solution (Python):
import math

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

for i in range(1, n + 1):
    if i > k:
        res += 1 / n
    else:
        c = math.ceil(math.log(k / i, 2))
        res += (1 / n) * (0.5 ** c)

print(res)

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

P=0
for i in range(1,N+1):
    if i < K:
        p = float((1/N)*(1/2)**np.ceil(np.log2(K/i)))
    elif  i >= K:
        p = float(1/N)
    P += p
print(P)

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

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

Solution (Python):



import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

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



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

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

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

Solution (Python):
n, k = map(int, input().split())
ret = 0.0
for i in range(1, n + 1):
    tmp = 1.0 / n
    now = i
    while now < k:
        now *= 2
        tmp /= 2.0
    ret += tmp
print("{0:0.12f}".format(ret))

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

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

ans = 0

for i in range(1, N+1):
    point = i
    tmp = 1/N
    while True:
        if point >= K:
            ans += tmp
            break
        point *= 2
        tmp *= (1/2)

print(ans)

Solution (Python):
import math
import copy
import fractions
import numpy as np



def getInputNum():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList



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

ans = 0
for i in range(n):
    tmp = math.ceil(np.log2(k/(i+1)))
    tmp = max(0, tmp)
    ans += 1/pow(2, tmp)

ans = ans/n
print(ans)

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

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

Solution (Python):
import math
N,K=[int(s) for s in input().split()]
sum=0
for i in range(N):
  a=max([math.log(K/(i+1), 2),0])
  a=math.ceil(a)
  sum=sum+0.5**a
print(sum/N)

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

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

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

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

Solution (Python):
import numpy as np
n, k = map(int, input().strip().split(' '))
p = 0
for i in range(n):
  coin = np.ceil(np.log2( k/(i+1) ))
  if coin > 0:
    p = p + 1.0/n * 0.5**coin
  else:
    p = p + 1.0/n
print(p)

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

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

print(ans)

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

A = K

ans = 0

i = 0
last = K
while True:
    i += 1
    A = K/pow(2,i)
    num = last - math.ceil(A)
    if math.ceil(A) <= N:
        if last-1 >= N:
            num = N - math.ceil(A) + 1
        ans += (num / N) / pow(2,i)
    
    last = math.ceil(A)
    if A <= 1:
        break
    
    
if N >= K:
    ans += (N - K + 1) / N
    
print('{:.14g}'.format(ans))

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

ans = 0

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

Solution (Python):
def get_num_coin(ini_point, k):
  n = 0
  tmp_point = 0
  while tmp_point <= k-1:
    n+=1
    tmp_point = ini_point*(2**n)
  return n

n, k = map(int, input().split())
ans = 0
for ini_point in range(1, n+1):
  if ini_point >= k:
    ans += 1/n
    continue
  else:
    num_coin = get_num_coin(ini_point, k)
    ans += 1/n * (0.5**num_coin)
print(ans)

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

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

print(ans)

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

for i in range(N):
    for j in range(0,2**10):
        total=(i+1)*(2**j)
        if(total>=K):
            break

    bunsu[i]=1/(N*(2**j))

print(sum(bunsu))

Solution (Python):
import math

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

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

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

def main():

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

if __name__ == '__main__':
    main()

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)

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

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

print(result)

Solution (Python):
from math import log2,ceil
n,k = map(int,input().split())
start = max(0.0,float((n-k+1)/n))
top = min(n,k-1)
for i in range(top,0,-1):
  start += ((1/2)**ceil(log2(k/i)))/n
print(start)

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

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

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

import math

def main(): 

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

if __name__ == "__main__":
    main()

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

ans = 0.0
for i in range(1,n+1):
    if i >= k:
        ans += (1/n)
    else:
        get = (1/n)
        val = i
        while val < k:
            val *= 2
            get *= (1/2)
        ans += get
print(ans)

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

Solution (Python):
import math

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

for i in range(1, n+1):
    needed_times = math.ceil(math.log2(math.ceil(k/i)))
    win_rate += 1/n * 0.5 ** needed_times

print(win_rate)

Solution (Python):
N, K = map(int,input().split())
list = range(1,N+1)
ans=[0]*N
i = 1
j = 0

for n in reversed(list):
    while n*i < K:
        i = i*2
    ans[n-1] = i
for k in ans:
    j += 1/k*1/N

print(j)

Solution (Python):


def main(N,K):
    ans = 0
    for i in range(1,N+1):
        tmp = 1/N
        score = i
        count = 0
        while(K>score):
            score *= 2
            count += 1
        tmp /= (2**count)
        ans += tmp
    print(ans)

if __name__ == '__main__':
    N, K = map(int, input().split())
    main(N,K)

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

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

for i in range(1,n+1):
  t = i
  while i < k:
    i = 2*i
    a[t-1] = (1/2)*a[t-1]
print((1/n)*sum(j for j in 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:
        temp=i*1
        cnt=1
        while temp <k:
            temp*=2
            cnt/=2
        ans+=cnt/n

print(ans)

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

res = 0.0
for dice in range(1, n+1):
    tmp = dice
    cnt = 0
    while k > tmp:
        tmp *= 2
        cnt += 1
    res += (1 / n) * (0.5 ** cnt)

print(res)

Solution (Python):
import math
def dice_and_coin(n,k):
    ans = 0.0
    for i in range(1,n+1):
        if i >= k:
            ans += 1/float(n)
        else:
            flip = math.log(k,2) - math.log(i,2)
            ans += 1/float(n) * (0.5 ** math.ceil(flip))

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

if __name__ == '__main__':
    n,k = map(int,raw_input().split())

    dice_and_coin(n,k)

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

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

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

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

    prob = 0
    if K-1 < N:
        prob += (N-K+1)
    sub = 0
    for i in range(1, min(N, K-1)+1):
        count = 0
        v = i
        while v < K:
            v*= 2
            count += 1
        sub += pow(0.5, count)
    return (prob + sub)/N

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

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

Solution (Python):
import math

N,K=map(int,input().split())
def sis(K,N):
    n1=K/N
    n2=math.log2(n1)
    n3=int(n2)
    if n2>n3:
        n3+=1
    return n3
ans=0
for i in range(N):
    if i>=K:
        ans+=1/N
    else:
        ans+=1/((2**sis(K,i+1))*N)
print(ans)

Solution (Python):
import math

n, k = map(int, input().split())
res = 0
for i in range(1, n+1):
    a = k / i
    b = format(math.ceil(a) - 1, 'b')
    num = 0 if b == '0' else len(b)
    res +=  (1/n) *  (1/2)**num
print(res)

Solution (Python):
import math

def main():
  pos=0
  n,k=map(int,input().split())
  nmen=1/n

  for i in range(1,n+1):
    ajs=(-(-math.log2(k/i)//1))
    if ajs<=0: ajs=0
    pos+=nmen*0.5**ajs
  
  print(pos)
  
if __name__ == "__main__":
  main()

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

ans = 0
for n in range(1, n+1):
    
    cnt = max(0, math.ceil(math.log2(k/n)))
    ans += (1/2) ** cnt

print( ans*(1/n) )

Solution (Python):

from math import log2, ceil

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

    ans = 0
    for i in range(1, N+1):
        n = ceil(log2(K) - log2(i))
        if n > 0:
            ans += 0.5 ** n
        else:
            ans += 1

    return ans / N

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

Solution (Python):

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

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


    ans += (1/n * (0.5 ** count))

print(ans)

Solution (Python):

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

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

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

else:
	for i in range(1, N + 1):
		j = math.floor((math.log2((K - 1) / i)) + 1)
		ans += (1 / N) * (1 / 2) ** j

print(ans)

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

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

S = 0

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

print(S)

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

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

Solution (Python):

import sys
import math
from collections import defaultdict


sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]


mod = 10**9 + 7


def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))



N,K = II()

ans = 0.0

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

print(ans)

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

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

print(ans)

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


dp=[None for i in range(n+1)]


for i in range(n):
    i=n-i
    if i>=k:
        dp[i]=0
    else:
        j=2*i
        if j<=n:
            dp[i]=dp[j]+1
        else:
            count=1
            while j<k:
                count+=1
                j=2*j
            dp[i]=count
            


prob=0
for i in range(n):
    a=dp.pop()
    prob+=0.5**a
print(prob/n)

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

Solution (Python):

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

ans=0



for i in range(n):
  


  count=0
  score=i+1
  for j in range(30):
    if score>=k:
      break
    score=score*2
    count+=1

  ans+= 1/(2**count)
  
print(ans/n)

Solution (Python):
from math import ceil


INF = float("inf")
MOD = int(1e9 + 7)


def main():
    N, K = map(int, input().split())
    r = 0
    for n in range(1, N + 1):
        c = 0
        while n < K:
            n *= 2
            c += 1
        r += 0.5 ** c
    print(r / N)

main()

Solution (Python):
from sys import stdin
import math

N,K = [int(x) for x in stdin.readline().rstrip().split()]
prob1 = 0
prob2 = 0


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


for p in range(1, min(N+1, K)):
  prob2 += (0.5) ** math.ceil(math.log2(K/p)) / N
  
print(prob1 + prob2)

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

Solution (Python):
n, k = map(int, input().split())
ans = 0
s = 1/2
while k > 1:
    ans += s * min(n, k-1)
    k -= k//2
    s /= 2
ans /= n
print(1-ans)

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

ans = 0
for i in range(n):
    tmp = i+1
    p = 1/n
    while k > tmp:
        tmp *= 2
        p /= 2
    ans += p

print(ans)

Solution (Python):
prob = 0.0
N,K = map(int,input().split())
for n in range(1,N+1):
    num = 0
    c = n
    while c < K:
        num += 1
        c *= 2
    prob += (0.5 ** num) / N

print(prob)

Solution (Python):
import math
n, k = map(int, raw_input().split())
p = 0.0
for i in range(1,n+1):
    if i < k:
        x = math.ceil(math.log((float(k) / float(i)), 2))
        p += (float(1) / float(n)) * ((0.5) ** x)
    else:
        p += (float(1) / float(n))

print p

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

Solution (Python):
import math

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

ans = 0

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

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

Solution (Python):

n, k = [int(el) for el in input().split(' ')]
H = []
for i in range(1, n+1):
    h = 0
    while i < k:
        i = 2*i
        h += 1
    H.append(h)

total = 1/n * sum([(1/2)**h for h in H])
print(total)

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

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

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

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

Solution (Python):
import math


def solve():
    n, k = map(int, input().split())
    exp = 0
    for i in range(1,  n + 1):
        if i >= k:
            exp += 1
        else:
            dice_num = math.ceil(math.log2(k / i))
            exp += 0.5 ** dice_num
    return exp / n


if __name__ == "__main__":
    print(solve())

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

Solution (Python):
n, k = map(int, input().split())
r = 0
total = 0
for i in range(1, n + 1):
    t = i
    cnt = 0
    while True:
        if t >= k:
            total += 1 / n * (0.5) ** cnt
            break
        else:
            cnt += 1
            t *= 2
print(total)

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

for i in range(1,n+1):
    if i<=k-1:
        n1=i
        for j in range(1,k+1):
            n1=n1*2
            if n1<=k-1:
                continue
            else:
                win+=(1/n)*(1/2**j)
                break
    else:
        win+=1/n
        
print(win)

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

Solution (Python):
n,k = map(int,input().split())
ans = 0
def two(x,y):
    for i in range(0,10**9):
        if x >= y:
            return i
        x *= 2
        
for i in range(1,n+1):
    tmp = 1/n
    pro = two(i,k)
    if pro:
        tmp *= (1/2)**pro
    else:
        pass
    ans += tmp
print(ans)

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

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

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

Solution (Python):

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

n,k=getints()

res = 0.0

for i in range(1,n+1):
    d = i
    p = 1.0
    while d < k:
        p *= 0.5
        d *= 2
    res += p / n

print(res)

Solution (Python):
import math

n,k = map(int,input().split())
sum = 0
for i in range(1,n+1) :
    if i > k :
        sum += 1
    else :
        sum += math.pow(0.5,math.ceil(math.log2(k/i)))
print(sum/n)