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):
    n=0
    while i*2**n<K:
        n+=1
    ans+=1/2**n
print(ans/N)

Solution (Python):
n, k = map(int, input().split())
sumA=0
index=1
while index <= n:
    if index >= k:
        sumA+=1/n
    else:
        index2=0
        while index2 < 18:
            if index*(2**index2) >= k:
                break
            index2+=1
        sumA+=(1/n)*((1/2)**index2)
    index+=1
print(sumA)

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

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

ans = [i for i in range(1, n + 1)]
ans_list = []
for i in ans:
    key = i
    cnt = 0
    while key < k:
        key *= 2
        cnt += 1
    ans_list.append(cnt)
Ans = 0
for i in range(len(ans_list)):
    Ans += ((1 / n) * pow(1 / 2, ans_list[i]))

print(Ans)

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

def oo(n,x):
    count = 0
    while n < x:
        count += 1
        n *=2
    return count
for i in range(1,n+1):

    ans += ((1/2)**oo(i,k))/n

print(ans)

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

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

Solution (Python):
from math import *

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

def f(x):
    if x>=K: return 1
    kaidero = ceil(log2(K/x))
    return pow(2,-kaidero)

re = 0
for x in range(1,N+1):
    re += f(x)/N
print(re)

Solution (Python):


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


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

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

kakuritu = 0
for i in range(1,N+1):
    if K<=i:
        kakuritu += 1/N
    else:
        kaisuu = ceil(log2(K / i))

        kakuritu += 1/N * (1/2)**kaisuu

print(kakuritu)

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

coef = 1
pp = 1

answer = 0
if N >= K:
  answer += N-K+1 

while pp <= K:
  coef /= 2
  cnt = min(N,(K-1)//pp) - min(N,(K-1)//(pp<<1)) 

  answer += coef * cnt
  pp <<= 1
  
answer /= N
print(answer)

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

Solution (Python):

import math

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


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

    if i >= K:
        ans += 1
    else:
        ans += 2 ** (-math.ceil(math.log2(K / i)))

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

print(ans/N)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

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()
ans = 0
for i in range(1, N+1):
	if i >= K:
		ans += 1/N
	else:
		ans += (1/N) * ((1/2)**ceil(log2(K/i)))
print(ans)

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

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

Solution (Python):


import math


def main():
  n, k = map(int, input().split())
  p = 1.0
  v = 0
  c = 0

  while True:
    w = max(n - k + 1, 0)
    v += w * p
    c += w

    if k == 1:
      break

    n = min(k - 1, n)
    k = int(math.ceil(k / 2))
    p /= 2

  
  print('{:.9f}'.format(v / c))


if __name__ == '__main__':
  main()

Solution (Python):


n, k = map(int, input().strip().split())
total = 0
for i in range(1, min(n+1, k)):
	j = i
	x = 0
	while True:
		j *= 2
		x += 1
		if j >= k:
			break
	total += (1/n)*((1/2)**x)

for i in range(k, n+1):
	total += (1/n)


print(total)

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

ans = 0
import math

for i in range(1, N+1):
    if i < K:
        c = math.ceil(math.log2(K/i))
        ans += 1/N*(1/2)**c
    else:
        ans += 1/N

print(ans)

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

def needcount(cycoro, K):
    c = 0
    while cycoro * 2 ** c < K:
        c += 1
    return c

ans = 0
for i in range(1, N+1):
    ans += 1/N * (1/2) ** needcount(i, K)
print(ans)

Solution (Python):
from fractions import Fraction
from decimal import Decimal

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

ans = 0
for i in range(1, n + 1):
    j = i
    times = 0
    while j < k:
        j *= 2
        times += 1
    x = Fraction(1, n) * Fraction(1, 2 ** times)
    ans += x
print("{:.10f}".format(Decimal(ans.numerator) / Decimal(ans.denominator)))

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

res = 0
for i in range(1, N+1):
    tmp = i
    count = 1
    for j in range(1000):
        if tmp >= K:
            break
        tmp *= 2
        count *= (1/2)
        

    res += count

    
print(res/N)

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

Solution (Python):
def solve(N, K):
    p = 0
    for i in range(1, N + 1):
        prob = 1 / N
        point = i
        while point < K:
            point = point * 2
            prob = prob / 2
        p += prob
    return p


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

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

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

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

TWO = [2**i for i in range(0,18)]

ans = 0
for i in range(1,N+1):
    j = 0
    for t in TWO:
        if i*t >= K:break
        j += 1
    ans += 0.5 ** j
    
print(ans/N)

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


def calc(x):
    cnt = 1
    while x < K:
        cnt += 1
        x *= 2
    return cnt - 1


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

print(ans)

Solution (Python):
import math
N,K = map(int,input().split())
coin = []
win = 0
for i in range(1,N+1):
    coin.append(math.ceil(math.log2(math.ceil(K/i))))
for i in coin:
    win +=1/(2**i)
print(win/N)

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

ans = 0

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

Solution (Python):
import sys

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

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

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

    return ans


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

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

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

Solution (Python):
import math

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

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

print(prob)

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


def dice_count(dice):
    ret = 0
    while dice < k:
        dice *= 2
        ret += 1
    return ret


ans = 0
for i in range(1, n+1):
    ans += (1/2) ** dice_count(i)
print(ans / n)

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

Solution (Python):

import sys
import math

def solve(N: int, K: int):
    p = 0
    for i in range(1, N+1):
        if i < K:
            kaisu = math.ceil(math.log2(K / i))
            p += (1 / N) * (0.5) ** kaisu
        else:
            p += (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):
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools, random
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right; sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]
def mi(n): return [wi() for _ in range(n)]
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

n, k = wi()


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

print(ans)

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

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

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

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

def percentage(n):
  if n >= K:
    return 1
  
  return percentage(n * 2) / 2

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

print(ans)

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

for i in range(N):
    score = i+1
    j = 0
    while True:
        if score >= K:
            counts[i] = j
            break
        score *= 2
        j += 1
ans = sum([1 / (2 ** a) for a in counts]) / N
print(ans)

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

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

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

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

Solution (Python):
import math
N, K = map(int, input().split())
result = 0.0
for n in range(1, N + 1):
    if K <= n:
        result += 1 / N
        continue
    t = (K + n - 1) // n
    x = math.ceil(math.log2(t))
    result += 1 / N * (0.5 ** x)
print(result)

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

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

for i in range(1, n+1):
    if k <= i:
        ans += 1 /n
        continue
    c = math.log(k/i, 2)
    c = math.ceil(c)
    ans += pow(2, -c) / n

print(ans)

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

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

Solution (Python):
n, k = map(int, input().split())
ans = 0.0
prob = [1.0 / 2 ** i for i in range(20)]
for s in range(1, n + 1):
	t = 0
	while s < k:
		t += 1
		s *= 2
	ans += prob[t]
print(ans / n)

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

Solution (Python):


import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()


def main():
    N, K = MI()
    prob = fractions.Fraction()
    for i in range(1, N + 1):
        if i >= K:
            prob += 1
        else:
            k = K / i
            t = math.ceil(math.log2(k))
            prob += 1 / 2**t
    return float(prob / N)


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

Solution (Python):
import math

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



def calc_d(x, k):
    return int(math.ceil(math.log2(k/x)))


def submit():
    n, k = read_input()

    result = 0
    for i in range(1, n + 1):
        if i < k:
            result += math.pow((1/2), calc_d(i, k))
        else:
            result += 1.0

    print(result/n)


if __name__ == '__main__':
    submit()

Solution (Python):

def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
import math
n,k=IL()
ans=0
for i in range(1,n+1):
    if i>=k:
        ans+=1
    else:
        ans+=1/pow(2,math.ceil(math.log(k/i,2)))
print(ans/n)

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

def prob(i):
	score = i 
	pr = 1/n
	while score < k:
		score *= 2
		pr/=2
	return pr

ans = 0
for i in range(1, n+1):
	ans += prob(i)
print(ans)

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
import math
n, k = getList()
pn = 1 / n

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

print(ans * pn)

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

r = [0.5]
for i in range(50):
    r.append(r[-1] / 2)

ans = 0
for n in range(1,N+1):
    if n > K-1:
        ans += 1
        continue
    c = ceil(log2(K/n))
    ans += r[c-1]
print(ans/N)

Solution (Python):


from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7
BN = 2 ** 30

N, K = map(int, raw_input().split())
ans = 0
for i in range(1, N + 1):
    num = i
    S = BN
    while num < K:
        num *= 2
        S /= 2
    ans += S
print ans * 10 ** 15 / (BN * N) / float(10 ** 15)

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

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

res = 0
for i in range(N):
    p = i+1
    for j in range(30):
        if p * (2**j) >= K:
            res += 1 / N / (2**j)
            break

print(res)

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

j = 0
i = 1
while i <= N:
    s = 1
    while i * s < K:
        s *= 2
    j += 1 / s
    i += 1 

print(j / N)

Solution (Python):
import math

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

prob = 0
for i in range(N):
  if i + 1 < K:
    n = math.ceil(math.log(K / (i + 1), 2))
    prob += 1 / (N * (2 ** n))
  else:
    prob += (N - K + 1) / N
    break

print(prob)

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

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

print(Ans)

Solution (Python):
import math
n,k = map(int,input().split())
twos = [1]
i = 0
while 2*twos[i] <= 10**5:
    twos.append(twos[i]*2)
    i += 1
twos.append(twos[-1]*2)

ans = 0
for i in range(1,n+1):
    temp = 0
    while twos[temp] * i <= k-1:
        temp += 1
    ans += 1/n * 1/twos[temp]
print(ans)

Solution (Python):
def calc(x):
    return max((-(-K//x)-1).bit_length(), 0)
N, K = map(int, input().split())
ans = 0
for i in range(1, N+1):
    ans += 2**(20-calc(i))
print(ans/(2**20*N))

Solution (Python):
from math import log2, floor
n, k = map(int, input().split())
a = 1/n
ans = 0
for i in range(1, n+1):
    if i >= k:
        ans += a
        continue
    j = int(log2(k/i)) + 1
    if i*2**(j-1) == k:
        j -= 1
    ans += a/2**j
print(ans)

Solution (Python):



 
import sys
import math



 

fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile


mod=1000000007
 

def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans

def getval(a,k):
    val=1
    while(a<k):
        a*=2
        val/=2
    return val
 
 

t=1
for tt in range(t):
    
    n,k= map(int, sys.stdin.readline().split(' '))
    ans=0
    for i in range(1,n+1):
        ans+=getval(i,k)
    print(ans/n)
    
    
    

if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

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

print(ans)

Solution (Python):
n, k = map(int, input().split())
prob = [0.0] * k
for i in reversed(range(k)):
    if i * 2 >= k:
        prob[i] = 0.5
    else:
        prob[i] = prob[i * 2] / 2
ans = 0
for i in range(1, n+1):
    if i >= k:
        ans += 1
    else:
        ans += prob[i]
print(ans / n)

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

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

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

n = N
rate = 0
res = 0
while n > 0:
    if n >= K*(1/2)**rate:
        res += 1/N * (1/2)**rate
        n -= 1
    else:
        rate += 1
print(res)

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

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

ans = 0
for i in reversed(range(1, N+1)):
  n = 1
  while i < K:
    n <<= 1
    i <<= 1
  ans += 1 / n
print(ans / N)

Solution (Python):
def dice_and_coin(N: int, K: int)->int:
    ans = 0

    for n in range(1, N+1):
        if n < K:
            c = 0
            while n < K:
                n <<= 1
                c += 1

            ans += 1 / (1 << c)
        else:
            ans += 1

    return ans / N


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

    ans = dice_and_coin(N, K)
    print('{:.10f}'.format(ans))

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

res = 0
for i in range(1,n+1):
    cnt = 0
    now = i
    while True:
        if now >= k:
            break    
        now = now*2
        cnt+=1
    
    res += 1/(n*2**cnt)

print(res)

Solution (Python):
import math
from functools import reduce

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]


def get_nums_l():
    return [ int(s) for s in input().split(" ")]


def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

n,k = get_nums_l()

ans = 0
for init_score in range(1,n+1):
    score = init_score
    
    need = 0
    while score < k:
        need += 1
        score *= 2

    rate = 1 / 2**need
    ans += rate / n

print(ans)

Solution (Python):
from math import ceil, log2

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

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

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):
        score *= 2
        prob *= 0.5
        
    ans += prob
    
print(ans)

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

N,K=map(int,input().split())
ANS=max(0,N-K+1)




for i in range(1,30):
    ANS+=max(0,(N-math.ceil(K*pow(1/2,i))+1))*pow(1/2,i)-max(0,(N-math.ceil(K*pow(1/2,i-1))+1))*pow(1/2,i)

print(ANS/N)

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

Solution (Python):

from collections import defaultdict

def get_renzokuomote(goal, now_num):
    count = 0
    while now_num < goal:
        now_num *= 2
        count += 1
    return count



def main():
    saikoro, goal = map(int, input().split())
    data = defaultdict(float)
    ans = 0
    for i in range(1, saikoro + 1):
        now_num = i
        if now_num % 2 == 0:
            data[now_num] = data[now_num // 2] * 2
        else:
            rennzoku_omote = get_renzokuomote(goal, now_num)
            if rennzoku_omote == 0:
                ans += (saikoro + 1 - now_num) / saikoro
                break
            data[i] = (0.5 ** rennzoku_omote) / saikoro



    for ele in data.values():
        ans += ele
    print(ans)





if __name__ == '__main__':
    main()

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


def f(x):
    k = 0
    while x < K:
        x *= 2
        k += 1
    return k


ans = sum(
    1 / (2**f(i))
    for i in range(1, N + 1)
) / N

print(ans)

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

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

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,k = li()
ans = 0

for i in range(1, n+1):
    cur = i
    cnt = 0
    while cur < k:
        cnt += 1
        cur *= 2

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

print(ans)

Solution (Python):
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N,K = inpl()

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

print(ans)

Solution (Python):
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

sys.setrecursionlimit(10000)
INF = float('inf')

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

cnts = []
for n in range(1, N + 1):
    cnt = 0
    while n * (2 ** cnt) < K:
        cnt += 1
    
    cnts.append(1 / 2 ** cnt)

print(sum(cnts) / len(cnts))

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

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

prob_sum = 0

for i in range(1 , n+1):
	now = i
	prob = 1.0

	while now < k:
		now *= 2
		prob /= 2
	prob_sum += prob
print(prob_sum / n)

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

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

Solution (Python):
import math


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


if __name__ == "__main__":
    main()

Solution (Python):
def doubling(i, k):
    while i < k:
        i *= 2
    return i


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

Solution (Python):

import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, K: int):
    acc = 0
    for i in range(1, N+1):
        p = max(0, int(ceil(log2(K / i))))
        acc += (1 / N) * (1 / 2) ** p
    return acc 


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))  
    result = solve(N, K)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()

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

Solution (Python):
ans = 0

n,k = map(int,input().split())
prob = 1/n

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

	prob2 = pow(2,count)

	an = (1 / prob2)
	
	ans += an

ans = ans * prob
print(ans)

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)))
      if x >= 1:
            ans += (1/n)*(1/2)**x
      else:
            ans += (1/n)
      
print(ans)

Solution (Python):







import math, itertools, operator
from math import *
from math import factorial as fact
from itertools import permutations, combinations
from functools import reduce


from fractions import gcd

inf = float('inf')

def lcm(a, b):
    return a * b // gcd(a,b)

def perm(a, b):
    import scipy.special
    return scipy.special.perm(a, b, exact = True)

def comb(a, b):
    import scipy.special
    return scipy.special.comb(a, b, exact = True)

def dfact(n):
    import scipy.special
    return scipy.special.factorial2(n, exact = True)

def prod(l):
    return reduce(operator.mul, l)

def input_ints(inp = input, sep = ' ', conv = int):
    return map(conv, inp().split(sep = sep))




N, K = input_ints()

P = .0
for n in range(1, N+1):
    i = 0
    c = 0
    while n < K:
        n *= 2
        c += 1
    P += pow(.5, c) / N
print(P)

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

print(sum([0.5**max(0, math.ceil(math.log2(K/n))) for n in range(1, N+1)])/N)

Solution (Python):
import math


def required_num_coins(x, k):
    return max(0, math.ceil(math.log(k / x, 2)))


def compute_prob(n, k):
    return sum(2 ** (-required_num_coins(x, k)) for x in range(1, n + 1)) / n


def main():
    n, k = (int(z) for z in input().split())
    res = compute_prob(n, k)
    print("{:.12f}".format(res))


if __name__ == "__main__":
    main()

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

res = 0.0

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