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

s = []

for i in range(1,n+1):
    cnt = i
    j = 1
    while cnt < k:
        cnt = cnt *2
        j += 1
    s.append(j-1)

total = 0
for i in range(len(s)):
    p = (1/n)*(1/2)**s[i]
    total = total + p

print(total)

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

checker = [k]
x = k
while x > 1 :
    x /= 2
    checker.append(x)

percentage = []
for i in range(len(checker)):
    percentage.append(1/(n*2**i))

answer = 0
for i in range(1,n+1):
    for j in range(len(checker)):
        if i >= checker[j]:
            answer += percentage[j]
            break

print(answer)

Solution (Python):

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


K3 = []
ans = 0
count = 0  

for i in range(1, N+1):
    K1 = i
    K2 = 0
    count = 0
    while K1 < K:
        K1 = 2 * K1
        count = count + 1
    K2 = 1/N * (1/2)**count
    K3.append(K2)

for k in range(N):
    ans = ans + K3[k]
print(ans)

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

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

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

import math

max_it=int(math.log(n, 2))+1
mn_d=min(d,n)
p=0

for i in range(1,mn_d+1):
	for j in range(1,max_it+1):
		if i*2**j>=n:
			if i<n:
				p+=1/d*0.5**j
			break

if d>=n:
	p+=(d-n+1)/d

print(p)

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

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

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 /= 2
    ans += prob
print(ans)

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

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

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

ans = 0.0

p1 = min(k-1, n) / n
ans += 1.0 - p1

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

print(ans)

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

proba = 0
for i in range(1,N+1):
	deme = i
	con = 0
	while deme < K:
		deme *= 2
		con += 1
	proba += (1/N)*((1/2)**con)

print(float(proba))

Solution (Python):
from fractions import Fraction

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

proba = 0
for i in range(1,N+1):
	deme = i
	con = 0
	while deme < K:
		deme *= 2
		con += 1
	proba += (1/N)*((1/2)**con)

print(float(proba))

Solution (Python):

from math import ceil, log
n, k = list(map(int, input().split(' ')))
rate = 0
for i in range(1,n+1):
    x = ceil(log(k/i, 2))
    if x < 0:
        x = 0
    rate += (1/n)*pow(0.5, x)
print(rate)

Solution (Python):

from math import ceil, log
n, k = list(map(int, input().split(' ')))
rate = 0
for i in range(1,n+1):
    x = ceil(log(k/i, 2))
    if x < 0:
        x = 0
    rate += (1/n)*(1/2)**x

print(rate)

Solution (Python):

from math import ceil, log
n, k = list(map(int, input().split(' ')))
rate = 0
for i in range(1,n+1):
    x = ceil(log(k/i, 2))
    if x < 0:
        x = 0
    rate += (1/n)*(1/2)**x
print(rate)

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
  p = (1/2)**a * (1/n)
  ans += p
print(ans)

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

Solution (Python):
import numpy as np

N, K = [int(v) for v in input().split()]
p = 0

limit = N
if N - K + 1 > 0:
    p = (N - K + 1) / N
    limit = K-1


for i in range(1, limit+1):
    f = np.ceil(np.log2(K/i))
    p += (1/N) * np.power(1 / 2, f)
print(p)

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

p=0.0
for n in range(1,N+1):
    need = 0
    point = n
    while point < K:
        point *= 2
        need += 1
    p+=1.0/N*pow(0.5,need)
print(p)

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

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

Solution (Python):
n,k=map(int,input().split())
a=[]
i=0
if k>1:
    while len(a)==0 or a[-1]!=1:
        a.append((k-1)//(2**i))
        i+=1
else:
    a.append(0)
n1=len(a)
if n>=k:
    s=(n-k+1)/n
    for i in range(n1):
        if i!=n1-1:
            s+=(a[i]-a[i+1])/(n*(2**(i+1)))
        else:
            s+=a[i]/(n*(2**(i+1)))
else:
    s=0
    for i in range(n1):
        if i!=n1-1 and a[i]>=n>a[i+1]:
            s+=(n-a[i+1])/(n*(2**(i+1)))
        elif i!=n1-1 and n>a[i+1]:
            s+=(a[i]-a[i+1])/(n*(2**(i+1)))
        elif n>=a[i]:
            s+=a[i]/(n*(2**(i+1)))
print(s)

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

ans=0
l=[]

for i in range(1,n+1):
        a=i
        for j in range(0,20):
                if a<=k-1:
                        a=a*2
                else:
                        l.append(j)
                        break
for k in l:
        ans+=(1/n)*(1/2)**k
print(ans)

Solution (Python):
temp=input().split()
N=int(temp[0])
K=int(temp[1])

r=[]
for i in range(1, N+1):
  temp=i
  counter=0
  while temp<K:
    temp*=2
    counter+=1
    
  r.append(counter)
    
print(sum([pow(0.5, r[i]) for i in range(N)])/N)

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

Solution (Python):
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/2) ** x

print(ans/n)

Solution (Python):
import math

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

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

print(sum(table))

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

print(p / N)

Solution (Python):
def main():
    n, k = map(int, input().split())
    res = 0.0
    for i in range(1, n + 1):
        if i >= k:
            res += 1 / n
            continue
        ii = i
        j = 0
        while ii < k:
            ii *= 2
            j += 1
        res += 1 / n / (2 ** j)
    print(res)


if __name__ == "__main__":
    main()

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

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

ans = 0

for n in range(1, N+1):
    if n >= K:
        ans += 1.0
    else:
        tmp  = 1.0
        while n < K:
            tmp /= 2
            n   *= 2
        ans += tmp

ans /= N

print(ans)

Solution (Python):

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

ans = 0
for i in range(1, n + 1):
    tmp, cnt = i, 0
    while tmp < k:
        tmp *= 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, cnt = i, 0
    while tmp < k:
        tmp *= 2
        cnt += 1
    ans += (1 / n) * (1 / 2) ** cnt
print(ans)

Solution (Python):
import math

n, k = [int(x) for x in input().split()]
result = 0
if n >= k:
    result += (n - k + 1) / n
    result += sum(1 / 2 ** math.ceil(math.log(k / i, 2)) for i in range(1, k)) / n
else:
    result = sum(1 / 2 ** math.ceil(math.log(k / i, 2)) for i in range(1, n + 1)) / n

print('%.12f' % result)

Solution (Python):
import math
n, k = [int(e) for e in input().split()]
m = math.ceil(math.log(k, 2))
if k <= n:
  result = sum(1 / 2 ** math.ceil(math.log(k / i, 2)) for i in range(1, k)) / n
  result += (n - (k - 1)) / n
else:
  result = sum(1 / 2 ** math.ceil(math.log(k / i, 2)) for i in range(1, n + 1)) / n
print('%.12f' % result)

Solution (Python):
import numpy as np
import math

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

K_list = [K]
tmp = K

for i in range(1, K):
    if tmp < 1:
        break
    else:
        tmp = tmp / 2
        tmp2 = math.ceil(tmp)
        K_list.append(tmp2)

KN_list = []
count = 0

for i in range(len(K_list)):
    if K_list[i] > N :
        count += 1
        pass
    elif K_list[i] == N:
        KN_list.append(K_list[i])
    else:
        KN_list.append(K_list[i])  
if N+1 not in KN_list:
    KN_list.insert(0, N+1)



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

ans = ans/N

print(ans)

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

proba = 0
for gotvalue in range(1, N + 1):
    if gotvalue < K:
        proba += (0.5**ceil(log2(K / gotvalue))) / N
    else:
        proba += 1 / N
print(proba)

Solution (Python):
import math
import numpy as np

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

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

prob /= N
print(prob)

Solution (Python):
from math import log, ceil

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

ans = 0
mul2 = 2 ** ceil(max(log(K / N, 2), 0))
sum2 = 2 ** (ceil(log(K, 2)) - ceil(max(log(K / N, 2), 0)))

for i in range(N, 0, -1):
    if i * mul2 < K:
        mul2 *= 2
        sum2 //= 2
    ans += sum2

print(ans / (N * 2 ** ceil(log(K, 2))))

Solution (Python):
n,k=map(int,input().split())
ans=0
for i in range(1,n+1):
  cnt=0
  tmp=1
  while i*tmp < k:
    tmp*=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):
    if i<k:
        c = 0
        num = i
        while num*2 < k:
            num *= 2
            c += 1
        else:
            c += 1
        rate = float(1/n) * float((1/2)**c)
    else:
        rate = float(1/n)
    ans += rate
print(ans)

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

win = 0

for t in range(1, min(K, N+1)):
    win += ((0.5)**(int(math.log2(K)-math.log2(t)-1e-10)+1))
win *= (1/N)

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

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

Lmax = 1
Rmin = N

P = [0.0]*(N+1)

for i in reversed(list(range(1, N+1))):
    if i >= K:
        P[i] = 1/N
    elif i*2 > N:
        p = 1/N
        current_point = i
        while current_point < K:
            p *= 1/2
            current_point *= 2
        P[i] = p
    else:
        P[i] = P[i*2] * (1/2)


print(sum(P))

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

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

Solution (Python):
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	n,k = map(int,input().split())
	ans = frac(float(0))
	scala = frac(1,n)
	for i in range(1,n+1):
		if(i>k):
			ans += frac(float(1)) * scala
		else:
			ans += frac(1,2**(math.ceil(math.log(k/i,2)))) * scala
	print(float(ans))

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Solution (Python):
def main():
    N, K = list(map(int, input().split()))
    ans = 0
    for i in range(1, N+1):
        times = 0
        while(1):
            if (i * pow(2, times) >= K): break
            times += 1
        ans += (1.0/N) * pow(0.5, times)

    print(ans)

main()

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

Solution (Python):



import math

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


step_1_p_list = [1 / n for x in range(1, n+1)]


step_2_p_list = []

for saikoro in range(1, n+1):
    if saikoro >= k:
        step_2_p_list.append(1)
        continue

    a, b = math.modf(math.log2(k/saikoro))
    if a == 0:
        must_win_n = b
    else:
        must_win_n = b + 1
    must_win_n = int(must_win_n)
    
    
    step_2_p_list.append((1/2) ** must_win_n)




p_list = []

for step_1_p, step_2_p in zip(step_1_p_list, step_2_p_list):
    p_list.append(step_1_p * step_2_p)


ans = sum(p_list)
print(ans)

Solution (Python):
import math
n,k=map(int,input().split())
def prob(n,k):
	if(n>=k):
		return 1
	else:
		return(0.5**(math.ceil(math.log(k/n,2))))
i=1
s=0
while(i<=n):
	s+=prob(i,k)
	i+=1

s/=n
print(s)

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

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

Solution (Python):
import math

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

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

print(p/n)

Solution (Python):
def prob(point, p, K):
    if point >= K:
        return p
    else:
        return prob(point * 2, p * 0.5, K)

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

p_arr = []
for i in range(N):
    dice = i + 1
    p_arr.append(prob(dice, 1/N, K))

print(sum(p_arr))

Solution (Python):
N, K = list(map(int, input().split()))
P_n = [0]*N
pro = 1.0
pow = 0
for i in range(N - 1, -1, -1):
	while (i+1)*(2**pow) < K:
		pow +=1
		pro /=2
	P_n[i] = pro

print(sum(P_n)/N)

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

ans = 0

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

print(ans)

Solution (Python):
a = input().split()
a = [int(i) for i in a]

kakuritu = 0
for i in range(1, a[0] + 1):
    num = i
    kakuritu_count = a[0]
    while (True):
        if (num >= a[1]):
            break
        num *= 2
        kakuritu_count *= 2

    kakuritu += 1/kakuritu_count

print(kakuritu)

Solution (Python):
def win(i,k):
    t=0
    while i<k:
        i=i*2
        t+=1
    return t

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

for i in range(1,n+1):
    prob+=(1/n)*((1/2)**win(i,k))
print(prob)

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) / N

print(ans)

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

throw = [0 for i in range(N)]
times = 0
for i in range(N, 0, -1):

    while K / (i * 2 ** (times)) > 1:
        times += 1
    throw[i-1] = 1/N*pow(1/2, times)



ans = 0
for i in throw:
    ans += i
print(ans)

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

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

print(p / N)

Solution (Python):
N,K = (int(x) for x in input().split())

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

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

pro = 0

for i in range(1,min(N+1,K)):
	count = 1
	for _ in range(int(K**0.5)+1):
		if i * 2 < K:
			count += 1
			i = i * 2
	pro += (1/N) * (1/2) ** count

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

print(pro)

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

print(ans/n)

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

m = math.ceil(math.log2(k) - math.log2(1))

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

a = (ans/(2**m)+ans_)/n
print(a)

Solution (Python):
import math

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

w = 0
for i in range(1,n+1):
    
    j = max(0,math.ceil((math.log((k/i),2))))
    w = w + (1/n) * (1/2)**j
print(w)

Solution (Python):
import sys

input = sys.stdin.readline

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

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

    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
N, K = map(int, input().split())
def count(x, y):
    cnt = 0
    while x < y:
        x = x * 2
        cnt += 1
    return(cnt)

p = [0 for _ in range(N)]
for i in range(1, N + 1):
    p[i - 1] = 0.5 ** count(i, K)
print(sum(p) / N)

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

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

Solution (Python):
n,k = map(int, input().split())
fund = 1/n
ans = 0
for i in range(1,n+1):
    if i >= k:
        ans += fund
    else:
        ii = i
        cond = 1
        temp = 0
        while cond:
            ii *= 2
            temp += 1
            if ii >= k:
                cond = 0
        ans += fund * ((1/2) ** temp)
print(ans)

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

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

Solution (Python):
import math

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

print(ans)

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

ans = 0

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

print(ans)

Solution (Python):
import math
n, k = (int(i) for i in input().split()) 
p = 0
for i in range(1,n+1):
  if i < k:
    x = math.ceil(math.log2(k/i))
    temp = 0.5 ** x / n
  else:
    temp = 1 / n
  p = p + temp
print(p)

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

coin = [0] * N
for i in range(len(coin)):
    cnt = 0
    v = i + 1
    while v < K:
        cnt += 1
        v *= 2
    coin[i] = cnt
    
ans = 0
for v in coin:
    ans += 0.5 ** v
print(ans / N)

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

Solution (Python):
import sys
import numpy as np


def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    exps = np.ceil(np.log2(np.ceil(K / np.arange(1, N+1))))
    ans = 1. / N * np.sum(0.5 ** exps)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
nk = input().split(" ");
n = int(nk[0]);
k = int(nk[1]);

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

Solution (Python):
N,K = map(int,input().split())
probabilities = [[] for _ in range(N)]

def GetCounts(number):
    cnt = 0
    quotient = K/number
    while(quotient>1):
        quotient /= 2
        cnt += 1
    return cnt

for i in range(N):
    probabilities[i] = (1/N)* pow(0.5,GetCounts(i+1))
print(sum(probabilities))

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

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

Solution (Python):
n,k=map(int,input().split())
import math
a=0
b=[]
c=0
d=[0 for i in range(n)]
for i in range(n,0,-1):
    while(True):
        if(pow(2,c)*i>=k):
            d[i-1]=c
            break
        c+=1
for i in range(n):
    a+=pow(2,d[0]-d[i])
print('{0:.10f}'.format(a/(pow(2,d[0])*n)))

Solution (Python):
import sys
import math
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [N, K] = string_to_int(inputs[0])

    ret = 0.0
    for i in range(1, N+1):
        score = i
        count = 1
        tmp = 1.0 / N
        while score < K:
            score *= 2
            count += 1
            tmp *= 0.5
        ret += tmp

    return ret


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Solution (Python):
n, k = list(map(int, input().split()))
l = list(range(1, n + 1))

count = 0
for i in range(len(l)):
    if l[i] < k:
        while True:
            l[i] = l[i] * 2
            count += 1
            if l[i] >= k:
                l[i] = (1 / n) * (0.5 ** count)
                count = 0
                break
    else:
        l[i] = (1 / n)
print(sum(l))

Solution (Python):
n, k = list(map(int, input().split()))
l = list(range(1, n + 1))
count = 0
for i in l:
    if i < k:
        while True:
            l[i - 1] = l[i - 1] * 2
            count += 1
            if l[i - 1] >= k:
                l[i -1] = (1 / n) * (0.5 ** count)
                count = 0
                break
    else:
        l[i -1] = (1 / n)
print(sum(l))

Solution (Python):
n, k = list(map(int, input().split()))
l = list(range(1, n + 1))

for i in l:
    if i < k:
        for r in range(1, 18):
            l[i - 1] = l[i - 1] * 2
            if l[i - 1] >= k:
                l[i -1] = (1 / n) * (0.5 ** r)
                break
    else:
        l[i -1] = (1 / n)
print(sum(l))

Solution (Python):
a, b = map(int, input().split())
c = 0
for i in range(1, a+1):
    d = 0
    e = i
    while True:
        if e >= b:
            c += (1 / a) * (0.5 ** d)
            break
        d += 1
        e *= 2
print(c)

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

Solution (Python):
import math

N,K = map(int,input().split())
sum = 0
max2 = math.ceil(math.log2(K)) 
for i in range(1,N+1):

    
    if i == K:
        sum += (2 ** max2) * (N-K+1)
        break

    R = math.ceil(math.log2(K / i))
    r = max2 - R

    sum += 2 ** r

mother = N * 2 ** max2
answer = sum/mother

print(answer)

Solution (Python):
N, K = map(int, input().split())
coins = []
for i in range(1, N+1):
	m = i
	cnt = 0
	while m < K:
		cnt += 1
		m *= 2
	coins.append(cnt)
p6 = 0
for i in range(0, N):
	p6 += 1 / (2**coins[i])
print(round(p6/N, 10))

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

sum_p = 0
for i in range(1, N+1):
    if i >= K:
        sum_p += 1/N
    else:
        n_powers = 1
        while True:
            if i * (2 ** n_powers) >= K:
                break
            n_powers += 1
        sum_p += 1/N * 0.5 ** n_powers

print(sum_p)

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

print(ans)

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

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

for i in range(n):
    cnt = 0
    dice = i+1
    if(dice>=k):
        res = (n-dice+1)/n
        ans += res
        break
    for j in range(k):
        dice *= 2
        if(dice >= k):
            cnt += 1
            break
        elif(dice < k):
            cnt += 1        
    tmp  = 1/n * (1/2)**cnt

    ans += tmp

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

Solution (Python):
import math

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

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

print(ret)

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

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

    total_prob = 0.0
    for i in range(1, N+1):
        res = i
        prob = 1 / N
        while res < K:
            prob *= 0.5
            res *= 2

        total_prob += prob

    print(total_prob)


if __name__ == '__main__':
    main()

Solution (Python):
import math

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




A = 0
B = []

a = 0

for n in range(1, N+1):
    if K/n > 1:
        i = math.ceil(math.log2(K/n))
        a += 2 ** (N+1-i)
        B.append(a)
    else:
        a += 2 ** (N+1) * (N + 1-n)
        break








    



print(a/(2**(1+N))/N)

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

for i in range(1, N+1):
    tmp = 1.0 / N
    if i < K:
        point = i
        while point < K:
            point *= 2
            tmp /= 2
        result += tmp
    else:
        result += tmp

print("{:.12f}".format(result))

Solution (Python):


import math

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

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

print(ans)

Solution (Python):
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

N, K = LI()

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

Solution (Python):
import math

n, k = [int(elem) for elem in input().split()]

res = 0.0
for i in range(1, n+1):
  if not (k//i) == 0:
    if (k/i) == (k//i):
      if math.log2(k//i) == int(math.log2(k//i)):
        x = int(math.log2(k//i))
      else:
        x = int(math.log2(k//i)) + 1
    else:
      x = int(math.log2(k//i)) + 1
  else:
    x = 0
  res += (1/n) * (0.5 ** x)
print(res)

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

result = 0
for i in range(N+1)[1::]:
    prod = i
    cnt = 0
    if i >= K:
        result += (N - i + 1) / N
        break
    else:
        while True:
            prod *= 2
            cnt += 1
            if prod >= K:
                result += 1 / (N*(2**cnt))
                break
print(result)