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

Solution (Python):
import math
 
N, K = map(int, input().split())
 
def f(n, k):
    return 0.5 ** math.ceil(math.log2(k/float(n)))
ans = 0
if K > N:
    for n in range(1, N+1):
       ans += f(n, K) * 1/N
       
else:
    for n in range(1, K):
        ans += f(n, K) * 1/N
    ans += float(N-K+1)/N
    
print(ans)

Solution (Python):
import numpy as np

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

n = np.arange(1,N+1)
k = np.ceil( np.log10(K/n)/np.log10(2.0) )
k[k < 0.0] = 0.0
ans = np.sum( 0.5**(k)/N )

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

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

lst = []
def kakuritu(val, base):
    num = 1
    while base >= val:
        val = val * 2
        num = num / 2
    num2 = (1/N) * num
    lst.append(num2)

n = 1
while n <= N:
    kakuritu(n, K-1)
    n = n + 1
ans = sum(lst)
print(ans)

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

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

print(p)

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

pro_list = []
for i in range(1,N+1):
	if i<K:
		try_number = math.ceil(math.log2(K/i))
		pro_list.append(1/ (N * 2**try_number) )
	else:
		pro_list.append(1/ N )
print(sum(pro_list))

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

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

    d = (2**p)
    sc = 1/(n*d)
    ttl += sc

print(ttl)

Solution (Python):
N, K = list(map(int, input().split()))
t = []
for i in range(1, N+1):
  c = 0
  x = i
  while x<K:
    x <<= 1
    c += 1
  t.append(c)
tx = max(t)
print(1.0 * sum([1<<(tx-ti) for ti in t]) / (1<<tx) / N)

Solution (Python):
from fractions import Fraction

n, k = [int(i) for i in input().split(" ")]
p = Fraction(0, 1)

def int_log(x, y):
    r = 0
    while x < y:
        x *= 2
        r += 1
    return r

for i in range(1, n + 1):
    if i >= k:
        p += Fraction(1, n)
    else:
        p += Fraction(1, n * 2**int_log(i, k))

print('{:.10f}'.format(float(p)))

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


ans = 0
for i in range(1, N + 1):
    
    need_omote = max(math.ceil(math.log2(K / i)), 0)
    ans += math.pow(0.5, need_omote)
print(ans / N)

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

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

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

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

for i in range(1,min(n,k)+1):
  j = float(math.ceil(math.log(k/i)/math.log(2)))
  ans += float((1/n)*(1/2)**j) 
if k<n:
  ans += float((n-k)*1/n)
  
print(ans)

Solution (Python):
import random

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

for first_score in range(1, n + 1):
    if first_score >= k:
        pro += 1 / n
    else:
        i = 1
        while True:
            if first_score * (2 ** i) >= k:
                break
            i += 1
        pro += 1 / ((2 ** i) * n) 

print(pro)

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

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

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

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

Solution (Python):
from math import log2, ceil

N, K = map(int, input().split())
ans = 0
max_pow = ceil(log2(K))
for n in range(1, N + 1):
    ans += 2 ** (max_pow - max(0, ceil(log2(K / n))))
print(ans / (N * 2 ** max_pow))

Solution (Python):
import math

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

def f(n, k):
    return 0.5 ** math.ceil(math.log2(k/float(n)))
ans = 0
if K > N:
    for n in range(1, N+1):
       ans += f(n, K) * 1/N
       
else:
    for n in range(1, K):
        ans += f(n, K) * 1/N
    ans += float(N-K+1)/N
    
print(ans)

Solution (Python):
import math

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

s = 0
logK = math.log(k)
log2 = math.log(2)
for i in range(n):
    p = i + 1
    prob = 1
    while p < k:
        p *= 2
        prob *= 0.5
    s += prob
print(s / n)

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

Solution (Python):
from math import ceil, log2

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

Pr = 0.0
for dice in range(1, min(N + 1, K)):  
    
    k = ceil(log2(K / dice))
    Pr += 1.0 / (2 ** k)

if K <= N:  
    Pr += N - K + 1

Pr /= N
print(Pr)

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

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

Solution (Python):
n,k = map(int,input().split())
ans = 0
def rep(a,b):
    m = 0
    while a<b:
        a = a * 2
        m += 1
    return m

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

Solution (Python):
N, K = map(int, input().split())
proba = 0
for n in range(0, N+1):
    for ii in range(18):
        if n * (2 ** ii) >= K:
            proba += (1 / N) * (0.5 ** ii)
            break

print(proba)

Solution (Python):
import math
a=[int(i) for i in input().split()]
ans=0
for i in range(1,a[0]+1):
  if i>=a[1]:
    ans+=1/a[0]
  else:
    n=0
    while  i*2**n<a[1]:
      n+=1
    ans+=(1/a[0])*1/2**n
print(ans)

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

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

Solution (Python):
n, k = map(int,input().split())
per = 0
for i in range(1, n+1):
    
    x = 0
    t = i
    while t < k:
        t *= 2
        x += 1
    
    per += 2**-x

print(per/n)

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

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


    while i < K:
        i *= 2
        ans *= 0.5
        count += 1
        

    sub += ans

print(sub)

Solution (Python):
def f(i, K):
  if i >= K:
    return 0
  
  upper = 50
  lower = 0

  while(upper - lower > 1):
    middle = int((upper + lower) / 2)
    if i * 2**middle >= K:
      upper = middle
    else:
      lower = middle

  return upper


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

ans = 0.0

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

print(ans)

Solution (Python):
def solve(n, k):
    res = 0
    for x in range(1, n+1):
        y = x
        while y < k:
            y *= 2
        res += 1.0 * x / y
    return res / n

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

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

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

for i in range(n):
    if i+1 < k:
        c = 0
        t = i+1
        while t < k:
            t *= 2
            c +=1
        
        ans += (1/n)*(1/2)**c
    
    else:
        ans += (1/n)*(n-i)
        break

print(ans)

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

prob_list = [2 ** -(math.ceil(math.log(K / n, 2))) if n < K else 1 for n in range(1, N + 1)]
prob = sum(prob_list) / N
print(prob)

Solution (Python):
def pow2(n):
	res = 1
	for i in range(0, n):
		res *= 2
	return res

counter = [0]
N, K = map(int, raw_input().split())
for i in range(1, N+1):
	m = i
	cnt = 0
	while m < K:
		m *= 2
		cnt += 1
	counter.append(cnt)
sum = 0
for i in range(1, N+1):
	sum += pow2(counter[1]-counter[i])
dv = N*pow2(counter[1])
print float(sum)/float(dv)

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

pro = []
q = 1

for i in range(N):
    for j in range(K):
        q = 2**j
        if (i+1)*q >= K:
            break
    pro.append((1/N) * (1/q))
    q = 1

ans = 0
for i in range(N):
    ans = ans + pro[i]

print(ans)

Solution (Python):
import math

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

p = 0.0

for i in range(n):
  i += 1
  num_required = 0.0
  if i < k:
    num_required = math.ceil(math.log2(k / i))
  p += 0.5 ** num_required

p /= n
print(p)

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

p = [0] * (n+1)

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



print(sum(p)/n)

Solution (Python):
import math

def main():
    n,k=list(map(int,input().split(' ')))
    ans = 0
    for i in range(1,min(n+1,k)):
        ans +=(1/2)**(-(math.log2(k/i)//-1))
    if n >= k:
        ans += (n-k+1)
    print(ans/n)

main()

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

Solution (Python):
import math

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

Solution (Python):
import math

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

prab = 0

for i in range(1, N+1):
    lo = math.log2(K/i)
    if lo < 0:
        lo = 0
    elif lo != int(lo):
        lo += 1

    prab += 1/pow(2., int(lo))

print(prab/N)

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

Solution (Python):
import sys
from numpy.random import *

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

kakuritu=0
for i in range(N):
    score = i+1
    ka=1/N
    while (score < K):
        ka/=2
        score*=2    
    kakuritu +=ka

print(kakuritu)

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

result = 0

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

print(result)

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

p = 0

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

print(p)

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

Solution (Python):
N,K=map(int,input().split())
ans=0
def wari(x):
  an=x
  b=0
  while an<K:
    an=an*2
    b=b+1
  return b

for i in range(N):
  a=i+1
  b=wari(a)
  ans=ans+(0.5)**b
  
print(ans/N)

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

Solution (Python):




list=input().split(" ")
num1=int(list[0])
num2=int(list[1])


probability_i=[]

for i in range(1,num1+1):
    count=0
    point=i
    while point<num2:
        point+=point
        count+=1
    prob=1/num1*(1/2)**count
    probability_i.append(prob)
ans=0
for j in probability_i:
    ans+=j
if ans>1:
    ans=1
print(ans)

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

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

print(p / N)

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


p = 0
for i in range(N):
    i = i+1
    l = i
    b = 0
    if K<=i:
        p += 1/N
    else:
        while 1:
            if K <= i:
                p += (1/N)*(1/(2**b))
                
                break
            else:
                b += 1
                i = i*2
print('{:.9f}'.format(p))

Solution (Python):
N, K = map(int, input().split())
ansall = 0
for i in range(1, N+1):
    for jyou in range(1, 18):
        if i >= K:
            ansall += 1
            break
        if i * (2 **jyou) >= K:
            ans = 1/ 2 ** jyou
            ansall += ans
            break
ANS = ansall / N
print(ANS)

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

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

    res = 0

    for i in range(1, N + 1):
        tmp_prob = 1 / N
        tmp_val = i
        while tmp_val < K:
            tmp_val *= 2
            tmp_prob /= 2

        res += tmp_prob

    print(res)


if __name__ == '__main__':
    main()

Solution (Python):
import math

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

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

print(ans / n)

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

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

n = 0
m = 1
res = []
while m<=N :
	n = 0
	while True :
		if m*pow(2,n) >= K :
			res.append(n)
			m+=1
			break
		n+=1
pr = 0
for n in res :
	pr += (1/N)*pow(1/2,n)
print(pr)

Solution (Python):
n = [int(s) for s in input().split(" ")]
k = n[1]
ans = 0

for l in range(n[0]):
    m = 0
    while (l+1)*2**m < k:
        m += 1
    ans += (1 / 2**m) * (1/ n[0])

print(ans)

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

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

p = 0

for i in range(1,N+1):
	num = 0
	count = 0
	if i < K:
		num = i
		while num < K:
			count = count + 1
			num = num * 2
	p = p + ((1 / N ) * pow(0.5,count))
print(p)

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

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

print(p)

Solution (Python):



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

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

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

Solution (Python):

import sys

import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n, k = readmi()
ans = 0
l = int(math.ceil(math.log2(k)))
for i in range(1, n + 1):
    s = 1 / (n)
    p = i
    t = 1
    for j in range(l):
        if p >= k:
            break
        p = p * 2
        t /= 2
    ans += (s * t)
print(ans)

Solution (Python):

import sys

import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

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

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

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

p = 0

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

print(p)

Solution (Python):
import math

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

win_prob = 0
for k in range(1, N+1):
  m = max(math.ceil(math.log2(K / k)), 0)
  win_prob += 1/N * 0.5**m

print(win_prob)

Solution (Python):
def prob(x, N, K):
    a = 1
    while x * (2 ** a) < K:
        a += 1
    return (1 / N) * ((1 / 2) ** a)

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

ans = sum(prob(i+1, N, K) for i in range(N)) if N < K else (N - K + 1)/N + sum(prob(i+1, N, K) for i in range(K-1))
print(ans)

Solution (Python):
import sys

n=input()
num = n.split()
a=int(num[0])
b=int(num[1])

def checkMultiNum(base, dst):
	num=0
	while True:
		if base >= dst:
			break;
		num+=1
		base = base * 2
		if base >= dst:
			break;
	return num

prob=1/a
res=0
if a >= b:
	res=prob*(a-(b-1))
for v in range(a):
	if v+1 >= b:
		break;
	num = checkMultiNum(v+1, b)
	tmp = prob * 0.5**num
	res += tmp

print(res)

Solution (Python):


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

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

print(ans)

Solution (Python):
import sys

n=input()
num = n.split()
a=int(num[0])
b=int(num[1])

def checkMultiNum(base, dst):
	num=0
	while True:
		if base >= dst:
			break;
		num+=1
		base = base * 2
		if base >= dst:
			break;
	return num

prob=1/a
res=0
for v in range(a):
	num = checkMultiNum(v+1, b)
	tmp = prob * 0.5**num
	res += tmp

print(res)

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

Prob = 0

for i in range(N):
  score = i+1
  if score >= K:
    Prob += 1/N
  else:
    mk = 1
    while  score*2**mk < K:
      mk += 1
    Prob += 1/N*0.5**mk

print(Prob)

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

for i in range(1,n+1):
    count = 0
    temp = i
    while temp < k:
        temp *= 2
        count += 1
    seq.append(count)

for i in range(n):
    result += 1/n * (0.5)**seq[i]
    
    
print(result)

Solution (Python):
'''
すぬけ君は 1 〜 N の整数が等確率で出る N 面サイコロと表と裏が等確率で出るコインを持っています。
すぬけ君は、このサイコロとコインを使って今から次のようなゲームをします。
まず、サイコロを 1 回振り、出た目を現在の得点とする。
得点が 1 以上 K−1 以下である限り、すぬけ君はコインを振り続ける。
表が出たら得点は 2 倍になり、裏が出たら得点は 0 になる。
得点が 0 になった、もしくは K 以上になった時点でゲームが終了する。

このとき、得点が K 以上である場合すぬけ君の勝ち、 0 である場合すぬけ君の負けである。

N と K が与えられるので、このゲームですぬけ君が勝つ確率を求めてください。

'''
import math

def main():
	'''
	メイン関数
	'''
	
	N, K = map(int, input().split())

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

		sum = sum + (1/N ) * (1/2) ** x  

	print(sum)



if __name__ == '__main__':
	main()

Solution (Python):
import math


strings = input().split()

n = int(strings[0])
k = int(strings[1])
prob = 0
'''
x = int(math.log(k / n, 2)) + 1
print(x)
prob = (1 / 3) * pow(1 / 2, x)
'''

for num in range(1, n+1):
    if num < k:
        x = math.ceil(math.log2(k / num))
        prob += pow(1 / 2, x)
    else:
        prob += 1
print(prob / n)

Solution (Python):
import math
N,K=[int(i) for i in input().split()]
res=0
for i in range(1,N+1):
	if i<K:
		po=math.ceil(math.log2(K/i))
		j=math.pow(0.5,po)
	else:
		j=1
	res+=j
print(res/N)

Solution (Python):
from decimal import *

dp = [0] * 100000

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

n_count = n
p_count = 0

while n_count:
    var = n_count * (2 ** p_count)
    if k - 1 < var:
        dp[p_count] += 1
    else:
        while var <= k - 1:
            var *= 2
            p_count += 1
        dp[p_count] += 1
    n_count -= 1

ans = Decimal(0)
for i, d in enumerate(dp):
    if d != 0:
        ans += Decimal(1/n) * (Decimal(1/2) ** i) * d

print(ans)

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

Solution (Python):
n,k = map(int,input().split())
s = [0] * n
sum = 0
if n >= k:
  
  
  sum += (n-k+1)/n
  b = k-1
  for i in range(1,18):
    a = b
    if k//2**i==k/2**i:
      b = k//2**i-1
    else:
      b = k//2**i
    for l in range(b,a):
      s[l] = i
    sum += (a-b)/(n*2**i)
else:
  
  
  b = n
  for i in range(1,18):
    a = b
    if k//2**i == k/2**i:
      b = min(k//2**i-1,b)
    else:
      b = min(k//2**i,b)
    for l in range(b,a):
      s[l] = i
    sum += (a-b)/(n*2**i)
'''b = min(n,k)-1
for i in range(1,18): 
  a = b
  b = k//(2**i)-1
  if b > a:
    b = a
  for l in range(b,a):
    s[l] = i
    sum += 1/(n*2**i)'''
print(sum)

Solution (Python):

import math


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

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

print(P)

Solution (Python):

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

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

print(ans)

Solution (Python):

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

res = 0.0

for i in range(1, n+1):
    point = i
    count_head = 0

    while point < k:
        point *= 2
        count_head += 1

    res += (1.0/n) * (0.5 ** count_head)

print res

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

p = [0]*N

for i in range(1, N+1):
    p[i-1] = 1.0/N

    score = i

    while score < K:
        p[i-1] *= 0.5
        score *= 2

print(sum(p))

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









point = 0

dice = float(1/ n)

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

print(ans)

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

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

win_rate_sum = 0
for i in range(n):
    i += 1
    tmp_rate = 1/n
    while i < k:
        
        i *= 2
        tmp_rate /= 2
    win_rate_sum += tmp_rate
print(win_rate_sum)

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

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

print(ans)

Solution (Python):
import numpy as np

N, K = map(int, input().split())
print(sum([0.5**max(np.ceil(np.log2(K/i)), 0) for i in range(1, N+1)]) / N)

Solution (Python):


argN,argK = list(map(int,input().split()))

if argN < argK:
  ans = 0.0
else:
  ans = (argN - argK) / argN


for i in range(1,min(argN,argK) + 1):
  check = i
  wkCount = 0
  while check < argK:
    check *= 2
    wkCount += 1
  ans += (1 / argN) * ((1 / 2) ** wkCount)
  

print(ans)

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

result =0

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

print(result/N)

Solution (Python):
import math

inputstrs = input().split()
n = int(inputstrs[0])
k = int(inputstrs[1])
p = map(lambda x: (0.5 ** math.ceil(math.log2(k) - math.log2(x + 1))) if x + 1 < k else 1, range(n))
print(sum(p) / n)

Solution (Python):

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

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

for i in range(1,n+1):
    tmp = 1/n
    now = i
    while now < k:
        now *= 2
        tmp /= 2
    ret += tmp
print(ret)

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

Solution (Python):
from math import log2,ceil
N,K=map(int,(input().split()))
l=m=0
if N<K:
    for k in range(1,N+1):
        x=(0.5**ceil(log2(K/k)))/N
        l+=x
if N>=K:
    for k in range(1,K):
        x=(0.5**ceil(log2(K/k)))/N
        l+=x
    m=(N-K+1)/N
print (l+m)

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

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

Solution (Python):
import sys
import math
import collections
import itertools
import array
import inspect


sys.setrecursionlimit(1000000)



def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))



def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in sys.stdin.readline().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v

def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False



dp = None


def main():
    N, K = li_input()

    ans = 0

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

main()

Solution (Python):
n,k=map(int,input().split())
p_lis = []
for x in range(1,n+1):
    if k>x:
        i=1
        while x*2<k:
            x*=2
            i+=1
        p_lis.append(((1/2)**i)*(1/n))
    else:
        p_lis.append(1/n)
print(sum(p_lis))

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

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

Solution (Python):
from math import ceil, log
n, k = map(int, input().split())
if n > k:
    ans = (n-k)/n
    l = k
else:
    ans = 0
    l = n

for i in range(1, l+1):
    ans +=  1 / (n * 2**ceil(log(k/i, 2)))
print(ans)

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

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

print(ans)

Solution (Python):


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

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

print(p)

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

countj = 0
tmpj = 0
counti = 0

while i <= N:
    j = 1
    j += tmpj
    while j < K:
        j *= 2
        countj += 1
    counti += (1/N) * ((1/2) ** countj)
    countj = 0
    tmpj += 1
    i += 1

print(counti)

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

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

print(ans)

Solution (Python):
input1 = input().split()
n = input1[0]
k = input1[1]

n = int(n)
k = int(k)

me = 1 
ten = 0
count = 0 
total = 0 

while me <= n:
    ten = me
    while ten < k:
        count += 1
        ten = ten * 2
    total += 1/n * (1/2) ** count
    count = 0
    me += 1

print(total)

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

twoSquare = [2**i for i in range(21)]

ans = 0
for i in range(N):
    n = i+1
    high = 20
    low = 0
    while high!=low:
        
        mid = (high+low)//2
        if n*twoSquare[mid] >= K:
            high = mid
        else:
            low = mid + 1
    ans += 1/N/twoSquare[high]
print(ans)

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

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