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 sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from math import factorial, sqrt, ceil, gcd
from functools import lru_cache, reduce
from decimal import Decimal
from operator import mul

INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)



class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def dijkstra_heap(s, edge, n):
    
    d = [10**20] * n
    used = [True] * n 
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


def combinations_count(n, r):
    if n < r:
        return 0
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def lcm(x, y):
    return (x * y) // gcd(x, y)


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


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


def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True



def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P


def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


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

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

Solution (Python):
import math

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

tmp = []
for i in range(1, n + 1):
    if i < k:
        num = (-1 * math.log2(k / i)) // 1 * -1 
        tmp.append(num)
    else:
        tmp.append(0)
        
ans = 0
for i in range(n):
    ans += 2**(tmp[0] - tmp[i])

print(ans / (n * 2**tmp[0]))

Solution (Python):
from decimal import Decimal
from fractions import Fraction
n, k = map(int, input().split())

prob = []

for base in range(1, n+1):
  p = 0
  while (base < k):
    p += 1
    base = base * 2
  prob.append(Fraction(1, n * (2 ** p)))
print(Decimal(sum(prob).numerator / sum(prob).denominator))

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
    continue
  x=(1/n)*pow(2,-1*math.ceil(math.log2(k/i)))
  ans+=x
print(ans)

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

def twice_num(i, limit):
    count = 0
    while i < limit:
        i *= 2
        count += 1
    return count

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

    ans = 0

    for i in range(1, n+1):
        p = Fraction(1, n)

        num = twice_num(i, k)
        if num > 0:
            p *= Fraction(1, 2**num)
        ans += p

    ans = Decimal(ans.numerator) / Decimal(ans.denominator)
    print("{:.12f}".format(ans))


main()

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

ans = 0
for i in range(1,n+1):
    num = i
    cnt = 0
    while True:
        if num >= k: break
        num *= 2
        cnt += 1
    prob = 1/pow(2,cnt)
    ans += prob

ans /= n
print(ans)

Solution (Python):
import math


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

ans = max(0, (n-k+1)/n)
for i in range(1, n+1):
    if i >= k:
        break
    x = math.ceil(math.log2(k/i))
    ans += (1/n) * (1/2)**x
print(ans)

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

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
n, k = map(int, input().split())
nums = []
ans = 0
for i in range(1, n+1):
    temp = i
    counter = 0
    while k > temp:
        temp *= 2
        counter += 1

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

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()
from decimal import *

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

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10**7) 
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right

from collections import deque


from collections import Counter

from itertools import accumulate,combinations,permutations

from heapq import heapify,heappop,heappush


from functools import lru_cache

from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    

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





if __name__ == "__main__":
    main()

Solution (Python):
from math import log2, ceil
n, k = map(int, input().split())
dic = {}
for i in range(1, n + 1):
  x = max(0, ceil(log2(k / i)))
  dic.setdefault(x, 0)
  dic[x] += 1
res = 0
for i in dic:
  res += (dic[i] * (2 ** -i))
print(res / n)

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

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

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

qs = 0
for i in range(1, N+1):
    if i >= K:
        qs += 1/N
    elif i < K:
        q = 1/N
        while i < K:
            q *= 1/2
            i *= 2
        qs += q
print(qs)

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):
        cnt = 0
        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())
border = []
inx = 0
while K > 1:
  border.append(K)
  K = (K + 1) >> 1
  inx += 1
border.append(1)
border.reverse()
pre = 1
cnt = []
for i in range(1, len(border)):
  if N < border[i]:
    cnt.append(N - pre + 1)
    break
  elif N == border[i]:
    cnt.append(border[i] - pre)
    cnt.append(1)
    break
  else:
    cnt.append(border[i] - pre)
    pre = border[i]
if N >= border[-1]:
  cnt.append(N - border[-1] + 1)
ans = 0
for c in cnt:
  ans += c * 0.5 ** inx
  inx -= 1
print(ans/N)

Solution (Python):
n,k=map(int,input().split());print(sum([1,4/2**len(bin(~-k//i))][i<k]for i in range(1,n+1))/n)

Solution (Python):
n,k=map(int,input().split())
print(sum([1,4/2**len(bin(~-k//i))][i<k] for i in range(1,n+1))/n)

Solution (Python):
n,k=map(int,input().split())
p=0
for i in range(1,n+1): p+=[1,4/2**len(bin(~-k//i))][i<k]
print(p/n)

Solution (Python):
n,k=map(int,input().split())
p=0
for i in range(1,n+1):
  if i<k: p+=4*0.5**len(bin(~-k//i))
  else: p+=1
print(p/n)

Solution (Python):
from fractions import Fraction
import math
n,k=list(map(int,input().split()))
ans=0
for i in range(1,n+1):
    if i>=k:
        ans+=(Fraction(1,n))
    else:
        x=int(math.log((k/i),2))
        if (k/i)%(2**x)!=0:
            x+=1
        ans+=Fraction(1,n*(2**x))
print(float(ans))

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

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

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

Solution (Python):
n, k = [int(v) for v in input().split()]
rate = []
for i in range(1, n + 1):
    if i >= k:
        rate.append(1)
        continue

    for s in range(1, k):
        score = i * (2 ** s)
        if score >= k:
            rate.append(1 / (2 ** s))
            break

print(sum(rate) / len(rate))

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

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

print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**6)

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

"""
i*2**t >= k
2**t >= k/i
tlog(2) >= log(k/i)
t >= log(k/i)/log(2)
"""

import math

ans = 0

for i in range(1,n+1):
    if i >= k:
        t = 0
    else:
        t = math.ceil(math.log(k/i)/math.log(2))
    ans += 1/pow(2, t)

ans /= n

print(ans)

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

Solution (Python):
from math import*

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

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

print(ans)

Solution (Python):
import math

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

ans = 0
for i in range(1, n+1):
    if i < k:
        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())

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())
print(sum(0.5 ** max(ceil(log2(k / i)), 0) for i in range(1, n + 1)) / n)

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

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

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

answer = 0
for value in range(1, N+1):
    number_of_front = 0
    while True:
        if value >= K:
            break
        value = value*2
        number_of_front += 1
    answer += 0.5 ** number_of_front

print(answer/N)

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

ans=0
for i in range(1,N+1):
    ans+=(1/N)*pow(1/2,max(ceil(log2(K/i)),0))

print(ans)

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

Solution (Python):
def solve(n, k):
    ans = []
    for dice in range(1, n+1):
        c = 0
        while dice < k:
            dice *= 2
            c += 1
        ans.append((1/n) * 1/(2**c))

    return sum(ans)


if __name__ == '__main__':
    n, k = map(int, input().split())
    print(round(solve(n, k), 10))

Solution (Python):
def num(i,k):
    n=1
    while True:
        if i*2*(2**(n-1))>=k:
            return n
            break
        n+=1

n,k=map(int, input().split())
c=0
i=1
for i in range(1,n+1):
    if i>=k:
        c+=1
    elif i*2<k:
        c+=(1/2)**num(i,k)
    else:
        c+=(1/2)
print((1/n)*c)

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

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

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

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

def check(now):
    if pow(2,now) * dice >= K:
        return True
    else:
        return False

def bisec(l, r):
    if r - l == 1:
        return r
    mid = (l + r) // 2
    if check(mid):
        return bisec(l,mid)
    else:
        return bisec(mid,r)

ans = 0
for dice in range(1,N+1):
    ans += 1 / pow(2,bisec(-1,30))
print(ans/N)

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

def check(now):
    if pow(2,now) * dice >= K:
        return True
    else:
        return False

def bisec(l, r):
    if r - l == 1:
        return r
    mid = (l + r) // 2
    if check(mid):
        return bisec(l,mid)
    else:
        return bisec(mid,r)

ans = 0
for dice in range(1,N+1):
    ans += 1 / pow(2,bisec(-1,100))
print(ans/N)

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


def check(now):
    if pow(2,now) * dice >= K:
        return True
    else:
        return False

def bisec(l, r):
    if r - l == 1:
        return r
    mid = (l + r) // 2
    if check(mid):
        return bisec(l,mid)
    else:
        return bisec(mid,r)
ans = 0
for dice in range(1,N+1):
    ans += pow(1/2,bisec(-1,100))
print(ans/N)

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

rate = 0

import math

for dice in range(1,N+1):
    
    cnt = math.ceil(math.log2(K/dice))
    if cnt < 0:
        cnt = 0
    rate += pow(1/2,cnt)

print(rate/N)

Solution (Python):

import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


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


def z():
    return int(input())


def S():
    return input()


def C(line):
    return [input() for _ in range(line)]


N, K = zz()




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

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

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

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

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 < 0:
        x = 0
    ans += (1/n) * (1/2)**x
print("{:.15f}".format(ans))

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

Solution (Python):
import math
N,K = (int(x) for x in input().split())
p = 0
for i in range(1,N+1):
  if i < K:
    times = math.ceil(math.log2(K/i))
    p = p + (1/N)*(1/2)**times
  else:
    p = p + (1/N)
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 += float(1/2)**c
  
print(ans/n)

Solution (Python):
import numpy as np
import math
 
N,K=list(map(int,input().split()))
 
ans = 0
for n in range(1,N+1):
    p = np.log2(K/n)
    p = math.ceil(p)
    
    if p < 0:
        p=0
    
    ans_temp = (1/N)*(1/2)**p
    ans+=ans_temp
    
print(ans)

Solution (Python):
n,k = map(int,input().split())
dk = [1,k,float("inf")]
ans = 0

while k > 2:
    k /= 2
    dk.append(int(-(-k//1)))
    
dk = sorted(dk)[::-1]
    
for i in range(1,n+1):
    for j in range(len(dk)):
        if i >= dk[j]:
            break
            
    ans += 1/n *(0.5**(j-1))
            
print(ans)

Solution (Python):
import math

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

if N >= K:
    sum_ = (N - (K - 1)) / N
else:
    sum_ = 0

for i in range(1, min(N + 1, K)):
    y = math.ceil(math.log2(K / i))
    sum_ += pow(1 / 2, y) / N

print(sum_)

Solution (Python):
import math

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

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

    x = math.ceil(math.log(K/i,2))
    sum += (0.5 ** x)

print(sum / N)

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

ans = 0

for i in range(1, N+1):
    M = 1.0/N
    S = i
    while S < K:
        S *= 2
        M /= 2
    ans += M

print(ans)

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

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

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

Solution (Python):
from decimal import Decimal
N, K = map(int, input().split())
t = 0
i = 1
while(i < K):
    t += 1
    i *= 2
under = 2**t

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

Solution (Python):
from decimal import Decimal
N, K = map(int, input().split())
t = 0
i = 1
while(i < K):
    t += 1
    i *= 2
under = 2**t

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

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
print(ans/n)

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

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


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

    ans = 0
    for n in range(1, N + 1):
        if n >= K:
            ans += 1
        else:
            ans += pow(2, -ceil(log2(K / n)))

    print(ans / N)
    return


if __name__ == '__main__':
    main()

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

Solution (Python):
import math

def main():
    n,k=map(int,input().split())
    s = 0
    for i in range(1, n+1):
        c=max(0, math.ceil(math.log(k/i, 2)))
        
        s += (1/2)**c
    print(s/n)
    
if __name__ == "__main__":
    main()

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

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

print(ans/N)

Solution (Python):
import sys
import time




import math
start=time.time()
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n,k = rl()
ans=0
for i in range(1,n+1):
    if i>=k:
        ans+=1/n
        continue
    if i>=k/2:
        ans+=1/2/n
        continue
    a=math.ceil(math.log2(k/i))
    ans+=(1/2)**a/n
    
print(ans)

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

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

print(res)

Solution (Python):
n,k=[int(x) for x in input().rstrip().split()]
ans=0
for i in range(1,n+1):
  now=i
  cnt=0
  while(now<k):
    now=now*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(N):
    if K<=i:
        ans+=1/N
    else:
        a=math.ceil(math.log(K/(i+1),2))
        ans+=1/N*0.5**a
print(ans)

Solution (Python):
N,K  = map(int, input().split()) 
POINT = [0]*N
OK = [False]*N
Pro = [0]*30
for i in range(N):
    POINT[i] = i+1


for i in range(len(Pro)):
    for j in range(N):
        if OK[j] == False:
            if POINT[j]>=K:
                OK[j] = True
                Pro[i] += 1
            POINT[j] *=2

ans = 0
for i in range(len(Pro)):
    ans +=  Pro[i]/(2**i)

print(ans/N)

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

ans = 0
count = 0

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

print(ans/n)

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

def num(i):
    j = 0
    while i < K:
        i *= 2
        j += 1
    return j

for i in range(1, N+1):
    ans += float(1) / (N*2**num(i))
print(ans)

Solution (Python):
from math import log2, ceil

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

ans = 0
for i in range(1, n+1):
    d = ceil(k/i)
    head = ceil(log2(d))
    ans += (0.5**head)/n
print(ans)

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


if __name__ == "__main__":
    main()

Solution (Python):
import math

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

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

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
print(ans/n)

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

cnt = 0
num = 1

while num < k:
    num *= 2
    cnt += 1

coin = 0

coin_num = k // 2


for i in range(1, n+1):
    num = i
    cnt = 0
    while num < k:
        num *= 2
        cnt += 1
    coin += float(0.5**cnt) 

print('{:.10f}'.format(coin / n))

Solution (Python):
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline



def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n, k = geta(int)
    ans = 0
    for i in range(1, n+1):
        l = i
        while l < k:
            l *= 2
        ans += i/l/n

    print(ans)


if __name__ == "__main__":
    main()

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

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

print(ans)

Solution (Python):
N,K = map(int,input().split())
ans_list = list()
for i in range(1, N+1):
  index = 0
  count = 0
  while i*(2**index) < K:
    index += 1
    count += 1
  ans_list.append(count)

ans = list(map(lambda x:0.5**x,ans_list))


print(sum(ans)/N)

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

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

print(format(rem, '.12f'))

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

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

import math

ans = 0
for n in range(1, N+1):
    continue_num = max(math.ceil(math.log(K, 2) - math.log(n, 2)), 0)
    ans += (1/N) * (1/2)**continue_num
    
print(ans)

Solution (Python):
def f(n,k):
  total = 0
  
  for u in range(1, n + 1):
    prob = 1.0/n 
    start = u
    p = 0
    while(start < k):
      start *= 2
      p+=1
    prob *= (0.5) ** p
    total += prob
  return total

n,k = map(int ,raw_input().split(' '))
print f(n,k)

Solution (Python):
from math import ceil, log, pow

def mi():
    return map(int, input().split())

def main():
    N, K = mi()
    ans = 0
    for i in range(1, N+1):
        ans += pow(0.5, max(0, ceil(log(K, 2)-log(i, 2))))/N
    print(ans)

if __name__ == '__main__':
    main()

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

total = 0
for i in range(1, n+1):
    tmp = max(math.ceil(math.log(k/i, 2)), 0)
    total += 0.5 ** tmp

print(total / n)

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

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

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

ans = 0
prob = 1
pow2 = 1
for i in range(N,0,-1):
    if i*pow2 >= K:
        ans += prob/N 
    else:
        while(1):
            prob = prob/2
            pow2 = pow2*2
            if i*pow2 >= K:
                ans += prob/N
                break
print(ans)

Solution (Python):
import math

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

def f(x, y):
    return math.ceil(math.log2(y / x))

ans = 0
for i in range(1, min(N, K) + 1):
    temp = (0.5) ** f(i, K)
    ans += temp
ans /= N

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

Solution (Python):
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n, k = map(int, input().split())
    ans = 0.0

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

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

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

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

print(res/N)

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