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 math
N,K = map(int,input().split())
cnt = 0
for n in range(1,N+1):
    x = 0
    while n*(2**x) < K:
        x += 1
    cnt += (0.5)**x

print(cnt/N)

Solution (Python):
import math
n,k=map(int,input().split())
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):
N, K = map(int, input().split())
ans = 0

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

Solution (Python):
def f(x, y):
    i = 1
    while i * x < y: i *= 2
    return 1 / i

n, k = map(int, input().split())
p = sum(f(i, k) for i in range(1, min(k, n + 1)))
print((max(0, n - k + 1) + p) / n)

Solution (Python):
import math

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

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

print('{:.9}'.format(ans / n))

Solution (Python):



import math

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


l = []

ln = n+0.5**9

l.append(math.ceil(ln-k) if ln-k>=0 else 0)

ln -= math.ceil(ln-k) if ln-k>=0 else 0

for _ in range(1,k+1):
    k/=2
    
    l.append(math.ceil(ln-k) if n-k>0 else 0)
    
    ln-=math.ceil(ln-k) if n-k>0 else 0
    
    if k<=1:
        break
ans = 0
for i in range(len(l)):
    
    ans += l[i]/n/2**i
print(ans)

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

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

Solution (Python):

N, K = map(int, input().split())
ret = 0
for i in range(1, N+1):
    tmp = 1.0/N
    now = i
    while(now<K):
        now *= 2
        tmp /= 2

    ret += tmp

print(ret)

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

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

print(ans)

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

ans = 0

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

print(ans)

Solution (Python):


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

diceProb = 1/N
tmp = 0
tmpVal = 0
prevCnt = 0

for n in range(1,N+1):
	tmpVal = n
	cnt = 0
	while tmpVal < K:
		tmpVal *= 2
		cnt += 1

	if prevCnt != cnt:
		
		prevCnt = cnt
	tmp += 2**(-cnt)


print("{:.12f}".format(tmp*diceProb))

Solution (Python):
n,g=map(int,input().split())
ans=0
basis=1/n
if g==1:
  print(1)
  exit()
  
A=[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072]

for i in range(1,n+1):
  A.append(g/i)
  A.sort()
  k=A.index(g/i)
  ans+=basis*(0.5**k)
  del A[k]
print(ans)

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

for x in range(1, N+1):
    prob = 1
    while x < K:
        prob *= 0.5
        x *= 2
    result += prob/N

print('{0:.9f}'.format(result))

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

for i in range(1, N+1):
    prob = 1
    x = i
    for j in range(i, K):
        if K <= x:
            break
        prob *= 0.5
        x *= 2
    result += prob/N

print('{0:.12f}'.format(result))

Solution (Python):
from sys import stdin
n, k = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 0

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

Solution (Python):
def c_dice_and_coin(N, K):
    ans = 0.0
    for i in range(1, N + 1):
        t, p = 1, 0
        while i * t < K:
            t *= 2
            p += 1
        ans += 1 / (2**p)
    return ans / N

N, K = [int(i) for i in input().split()]
print(c_dice_and_coin(N, K))

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

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

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

print('{0:.12f}'.format(result))

Solution (Python):

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

Solution (Python):


import numpy as np

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

sum_poss = 0
for n in range(1, N+1):
    m = 0
    poss = 1
    while n*2**m < K:
        m += 1
        poss /= 2
    sum_poss += poss/N
    



print(sum_poss)

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


def tell_power_number(number):
    i = 0
    while number * (2 ** i) < K:
        i += 1
    return i


ans = 0
if N <= K - 1:
    for k in range(1, N + 1):
        ans += 1 / N * (1 / 2) ** tell_power_number(k)
else:
    for k in range(1, K):
        ans += 1 / N * (1 / 2) ** tell_power_number(k)
    ans += (N - K + 1) / N

print(ans)

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

t = []
d = k
while(True):
  d = d / 2
  t.append(d)
  if d <= 1:
    break


t2 = []
nn = 1+n if n < k else k
for i in range(1, nn):
  for j in range(len(t)):
    if i >= t[j]:
      t2.append(j+1)
      break


t3 = [0.5]
for i in range(1, math.ceil(math.log(k, 2))):
  t3.append(t3[i-1]*0.5)


r = 0
for t in t2:
  r += t3[t-1]
r /= n
if n >= k:
  r += (n-k+1) / n
print(r)

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


def tell_power_number(number):
    i = 0
    while number * (2 ** i) < K:
        i += 1
    return i


ans = 0
if N <= K - 1:
    for k in range(1, N + 1):
        ans += 1 / N * (1 / 2) ** tell_power_number(k)
else:
    for k in range(1, K):
        ans += 1 / N * (1 / 2) ** tell_power_number(k)
    ans += (N - K + 1) / N

print(ans)

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

l = [0]
if N>=K:
  l[0] = N-K+1
now = K-1
cnt = 2
while now>=1:
  nx = now // 2
  if N > now:
    a = now-nx
  elif now >= N > nx:
    a = N - nx
  else:
    a = 0
  l.append(a)
  now = nx
  cnt *= 2


ll = len(l)
pp = 1
for i in range(ll):
  l[ll-i-1] *= pp
  pp *= 2

suml = sum(l)
print( suml/(pp/2)/N)

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

import math
P = 0
if N < K:
    for i in range(1,N+1):
        P += ((0.5)**(math.ceil( math.log2(float(K/i)) )))/N
else:
    P += (N-K+1)/N 
    for i in range(1,K):
        P += ((0.5)**(math.ceil( math.log2(float(K/i)) )))/N
print(P)

Solution (Python):
n, k = map(int, input().split())
ret = 0
for die in range(1, n + 1):
    cur = die
    p = 0
    while cur < k:
        cur <<= 1
        p += 1
    ret += 1 / n * (0.5 ** p)
print(ret)

Solution (Python):
import math

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


ans = 0
total = 0
for i in range(0,N):
	if i < K:
	
		dice_times = math.ceil(math.log2(K/(i+1)))
		total = total + (0.50000000000**dice_times)
		
	else:
		total += 1

print(total/N)

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

P = 0

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

print(P/N)

Solution (Python):
import math

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

ans = float(0)

Kd = float(0)
Nd =int(0)
i = int(1)


if N>=K:
    Nd = K-1
    ans += N-K+1

else:
    Nd = N

while Nd>=1 :
    Kd = K/(2**i)
    if Kd<=Nd:
        ans += (Nd - math.ceil(Kd) +1) / (2 ** i)

        if math.ceil(Kd)-math.floor(Kd)==0.0:
            Nd = math.ceil(Kd)-1
        else: Nd = math.floor(Kd)

    i +=1


ans = ans/N

print(ans)

Solution (Python):
import numpy as np

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


N,K=spaceinput()

res=0

for i in range(1,N+1):
    if K>i:
        tmp=np.ceil(np.log2(K/i))
        res+=(0.5**tmp)/N
    else:
        res+=1/N

    


print(res)

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

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

print(P / N)

Solution (Python):
n, k = (int(i) for i in input().split())
 
def win_num(f, k):
    i = 0
    F = f
    while F<k:
        F = f
        F = F*(2**i)
        i += 1
    if i == 0:
        return i
    else:
        return i - 1

ls = []
for f in range(n):
    wn = win_num(f+1, k)
    ls.append((1/n) * (1/2)**wn)
print(sum(ls))

Solution (Python):

import math

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

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

print(ans)

Solution (Python):
import math
N,K=map(int, input().split())
p=20
count=0
ans=0
for i in range(N):
  if (i+1)>=K:
    count+=1
  else:
    for j in range(20):
      if (i+1)*math.pow(2,j)>=K:
        ans+=math.pow(1/2,j)
        break
    
  
if N<K:
    print(1/N*ans)
else:
    print(count/N+1/N*ans)

Solution (Python):
import math

def getCount(K,i) :
    return math.log(K/i,2)

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

for i in range(1,N+1) :
    if i >= K :
        score += 1/N
        continue
    count = math.ceil(getCount(K,i))
    score += 1/N * (1/2)**count
print(score)

Solution (Python):
import math

N ,K = (int(i) for i in input().split())
ans = 0
for i in range(int(N)):
  if i < K:
    x = math.log2(K/(i+1))
    x_ceil = math.ceil(x)
    ans += pow(0.5,x_ceil)/N
  else:
    ans += 1/N

print(ans)

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

aaa = []

for i in range(1, a + 1):
    w = i
    cnt = 0
    while w < b:
        w = w * 2
        cnt += 1
    cntcnt = 0.5 ** cnt
    aaa.append(cntcnt)

print(sum(aaa) / len(aaa))

Solution (Python):
import math

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


ans = 0
for i in range(1,N+1):
	a = i
	b = 1
	while a < K:
		a *= 2
		b *= 0.50000000000
	ans += b


print(ans/N)

Solution (Python):
import math

N,K = map(int,input().split())
result = 0
N1 = 1.0/N
for i in range(N):
    k = i+1
    cnt = 0
    while(k<K):
        k = k*2
        cnt += 1
    result += math.pow(0.5, cnt)

print(result*N1)

Solution (Python):
def f(x, y):
    i = 1
    while x < y: i *= 2; x *= 2
    return 1 / i

n, k = map(int, input().split())
p = (max(0, n - k + 1) +
     sum(f(i, k) for i in range(1, min(k, n + 1)))) / n
print(p)

Solution (Python):

import math

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

sum = 0
for i in range(1, N+1):
    k = math.ceil(math.log2(K) - math.log2(i)) if i < K else 0
    p =  1 / (N * math.pow(2, k))
    
    
    sum = sum + p

print(sum)

Solution (Python):
import numpy as np
from decimal import Decimal

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

sum=0

for i in range(1,n+1):
    if i<k:
        cnt=0
        tempi=i
        while tempi<k:
            tempi*=2
            cnt+=1
        sum+=1/(n*(2**cnt))
    else:
        sum+=1/n

print(sum)

Solution (Python):
import math

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

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

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

Solution (Python):
hoge = input().split()
N = int(hoge[0])
K = int(hoge[1])
score = 0
kcount = 0
for i in range(1,N+1):
  buf = i
  while buf < K:
    kcount += 1
    buf = buf * 2
  score += (1/N) / pow(2,kcount)
  kcount = 0
  buf = 0
    
print(score)

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

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

Solution (Python):



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

    for i in range(1, n + 1):
        if i >= k:
            ans += 1
        else:
            m = 1

            while i * 2 ** m < k:
                m += 1

            ans += (1 / 2) ** m

    print(ans / n)


if __name__ == '__main__':
    main()

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

r = 0
for i in range(1, 1+n):
  t = i
  p = 1.0
  while(True):
    if t >= k:
      r += p
      break
    t *= 2
    p *= 0.5
print(r/n)

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

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

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

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

r = 0
for i in range(1, 1+n):
  t = i
  p = 1.0
  while(True):
    if t >= k:
      r += p
      break
    t *= 2
    p *= 0.5
print(r/n)

Solution (Python):
N, K = map(int, input().split())
prob_list = []
for i in range(1, N + 1):
    coin_prob = 1.0
    while i < K:
        i *= 2
        coin_prob /= 2
    prob_list.append((1 / N) * coin_prob)
print(sum(prob_list))

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

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

print(sum_tmp)

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

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

print(sum_tmp)

Solution (Python):
import math

def main():
    n, k = [int(c) for c in 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)

main()

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

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

print(sum_tmp)

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

    
    ans = 0
    for x in range(1, N+1): 
        kaisuu = ceil( log( K / x, 2))
        if x >= K:
            kaisuu = 0
        
        
        tmp = 1/N
        for i in range(kaisuu):
            tmp *= 0.5
        ans += tmp 
    
    print(ans)
        

    
if __name__ == "__main__":
    solve()

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

a = 0

for i in range(N):
  j = N - i
  b = 1

  while j < K:
      b /= 2
      j *= 2

  a += b

print(a / N)

Solution (Python):
n,k=map(int,input().split())
prob=0.0
if n>=k:
  prob+=(n-k+1)/n
mn=min(n+1,k)
for i in range(1,mn):
  check=i
  count=0
  while True:
    check*=2
    count+=1
    if check>=k:
      break
  prob+=pow(0.5,count)/n
print(prob)

Solution (Python):
N, K = map(int, input().split())
P = 0
for i in range(min(N,K-1)):
    tmp=1.0/float(N)
    now=i+1
    while now < K:
        now *= 2
        tmp /= 2
    P += tmp
if N > K-1:
    P += 1./float(N)*float(N-K+1)
print(P)

Solution (Python):


"""
Created on Tue Feb 26 17:52:43 2019

@author: nakamuratakayuki
"""
N, K = tuple(map(int,input().split()))
ans = 0

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

Solution (Python):
def sub():
    N, K = [int(e) for e in input().split(" ")]

    pOne = (N-K+1) / N
    if pOne < 0:
        pOne = 0.0

    M = min(K-1, N)
    k = 2
    count = 1
    tmpM = M + 0
    buf = []
    for i in range(M):
        tmpM = M-i
        while True:
            v = tmpM*k
            if v >= K:
                buf.append(count)
                break
            k = 2*k
            count = count + 1
    twos = [0.5]
    for _ in range(count-1):
        t = twos[-1] * 0.5
        twos.append(t)
    
    pp = [twos[b-1] / N for b in buf]
    pTwo = sum(pp)
    print(pOne + pTwo)
    


sub()

Solution (Python):
import math

N, K = map(int, input().split())
minNK = min(N, K-1)

sumA = 0

for i in range(1, minNK+1):
    c, k = 0, i
    while k < K:
        c, k = c+1, k*2
    
    sumA += ( math.pow(0.5, c) / float(N))


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

Solution (Python):
import math
N, K = (int(x) for x in input().split())
prob = 0
for i in range(1,N+1):
    a = i
    b = 1
    while a < K:
        a *= 2
        b *= 0.50000000000
    prob += b
print(prob / N)

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

Solution (Python):
import math
N, K = (int(x) for x in input().split())
prob = 0
for i in range(1,N+1):
    a = i
    b = 1
    while a < K:
        a *= 2
        b *= 0.50000000000
    prob += b
print(prob / N)

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
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 II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N, K = LI()
    ans = 0
    for i in range(1, N + 1):
        if i >= K:
            ans += 1
        else:
            times = -(-K // i)
            bits = (times - 1).bit_length()
            ans += 0.5 ** bits
    ans /= N
    return ans

print(main())

Solution (Python):
import numpy as np
import math

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

if N > K: 
    prob_base = (N-K) / N
    prob = 0
    
    for i in range(1, K+1):
        x = math.ceil(np.log2(K/i))
        prob += (1/N) * (1/2)**x
        
    print(prob_base + prob)
    
else:
    prob = 0
    for i in range(1, N+1):
        x = math.ceil(np.log2(K/i))
        prob += (1/N) * (1/2)**x
        
    print(prob)

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

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

    
    ans = 0
    for x in range(1, N+1): 
        kaisuu = ceil( log( K / x, 2))
        
        tmp = 1/N
        for i in range(kaisuu):
            tmp *= 0.5
        ans += tmp 
    
    print(ans)
        

    
if __name__ == "__main__":
    solve()

Solution (Python):
l = list(map(int, input().split()))
num = l[0]
k = l[1]
baro=[]
ans=[]
for j in range(1,num+1):
    for i in range (100000):
        if j * 2 **i >= k:
            baro.append(i) 
            break
for m in baro:
    ans.append((1/num)*(1/2)**m)

print(sum(ans))

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

    
    ans = 0
    for x in range(1, N+1): 
        kaisuu = ceil( log( K / x, 2))
        
        tmp = 1/N
        for i in range(kaisuu):
            tmp *= 0.5
        ans += tmp 
    
    print(ans)
        

    
if __name__ == "__main__":
    solve()

Solution (Python):
import numpy as np

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


N,K=spaceinput()

res=0

for i in range(1,N+1):
    if K>i:
        tmp=np.ceil(np.log2(K/i))
        res+=(0.5**tmp)/N
    else:
        res+=1/N

    


print(res)

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

ret = float(0)

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

print(ret)

Solution (Python):
from decimal import *

import math

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



result = 0

for i in range(1,N + 1):
    tmp = 1/N
    i_tmp = i
    while i_tmp < K:
        tmp /= 2
        i_tmp *= 2
        
    result += tmp
print(result)

Solution (Python):
N, K = list(map(int, input().split()))
prob = 0
for n in range(1, N+1):
  
  
  if(K <= n):
   prob = prob + 1
   continue
  else:
   
   
   len_bin_n = len(str(bin(n)))
   len_bin_k = len(str(bin(K)))
   min_rest_number_of_front = len_bin_k - len_bin_n
   if(K <= n * pow(2, min_rest_number_of_front)):
    prob = prob + 1/pow(2,min_rest_number_of_front)
    
   else:
    prob = prob + 1/pow(2,min_rest_number_of_front+1)
    
 
result = (1/N) * prob
print(result)

Solution (Python):
import math

N,K = map(int,input().split())
result = 0
N1 = 1.0/N
for i in range(N):
    k = i+1
    cnt = 0
    while(k<K):
        k = k*2
        cnt += 1
    result += math.pow(0.5, cnt)

print(result*N1)

Solution (Python):
N, K = list(map(int, input().split()))
prob = 0
for n in range(1, N+1):
  
  
  if(K <= n):
   prob = prob + 1
   continue
  else:
   
   
   len_bin_n = len(str(bin(n)))
   len_bin_k = len(str(bin(K)))
   min_rest_number_of_front = len_bin_k - len_bin_n
   if(K <= n * pow(2, min_rest_number_of_front)):
    prob = prob + 1/pow(2,min_rest_number_of_front)
    
   else:
    prob = prob + 1/pow(2,min_rest_number_of_front+1)
    
 
result = (1/N) * prob
print(result)

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

Solution (Python):
import math

N,K = map(int,input().split())
result = 0
N1 = 1.0/N
for i in range(N):
    k = i+1
    cnt = 0
    while(k<K):
        k = k*2
        cnt += 1
    result += math.pow(0.5, cnt)

print(result*N1)

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

    
    ans = 0
    for x in range(1, N+1): 
        kaisuu = ceil( log( K / x, 2))
        
        tmp = 1/N
        for i in range(kaisuu):
            tmp *= 0.5
        ans += tmp 
    
    print(ans)
        

    
if __name__ == "__main__":
    solve()

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

ret = float(0)

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

print(ret)

Solution (Python):
from decimal import *

import math

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



result = 0

for i in range(1,N + 1):
    tmp = 1/N
    i_tmp = i
    while i_tmp < K:
        tmp /= 2
        i_tmp *= 2
        
    result += tmp
print(result)

Solution (Python):
N, K = map(int, input().split())
P = 0
for i in range(min(N,K-1)):
    tmp=1.0/float(N)
    now=i+1
    while now < K:
        now *= 2
        tmp /= 2
    P += tmp
if N > K-1:
    P += 1./float(N)*float(N-K+1)
print(P)

Solution (Python):
n, k = map(int, input().split())
ans = 0
for i in range(1, n+1):
    for j in range(18):
        if i >= k:
            break
        i *= 2
    ans += (1 / n) * (0.5) ** j
print('{:.12f}'.format(ans))

Solution (Python):


import math

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

sum = 0
list = []
for n in range(1,N+1):
    if n < K:
        x = abs(math.log2(K/n))
        x_ceil = math.ceil(x)
        sum += pow(0.5, x_ceil)/N
    else:
        sum += 1/N

print(sum)

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

ret = float(0)

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

print(ret)

Solution (Python):
N, K = map(int, input().split())
P = 0
for i in range(min(N,K-1)):
    tmp=1.0/float(N)
    now=i+1
    while now < K:
        now *= 2
        tmp /= 2
    P += tmp
if N > K-1:
    P += 1./float(N)*float(N-K+1)
print(P)

Solution (Python):
N, K = map(int, input().split())
P = 0
for i in range(min(N,K-1)):
    tmp=1.0/float(N)
    now=i+1
    while now < K:
        now *= 2
        tmp /= 2
    P += tmp
if N > K-1:
    P += 1./float(N)*float(N-K+1)
print(P)

Solution (Python):
N, K = map(int, input().split())
P = 0
for i in range(min(N,K-1)):
    tmp=1.0/float(N)
    now=i+1
    while now < K:
        now *= 2
        tmp /= 2
    P += tmp
if N > K-1:
    P += 1./float(N)*float(N-K+1)
print(P)

Solution (Python):
import numpy as np

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


N,K=spaceinput()

res=0

for i in range(1,N+1):
    if K>i:
        tmp=np.ceil(np.log2(K/i))
        res+=(0.5**tmp)/N
    else:
        res+=1/N

    


print(res)

Solution (Python):
import math

def getCount(K,i) :
    return math.log(K/i,2)

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

for i in range(1,N+1) :
    if i >= K :
        score += 1/N
        continue
    count = math.ceil(getCount(K,i))
    score += 1/N * (1/2)**count
print(score)

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

b=1
S=0
a=0
m=0
for i in range(1,n+1):
    b=i
    for j in range(0,100000):
        if b>=k:
            m=j
            break
        else:
            b=b*2
            continue
    

    S=S+(1/(n*2**(m)))

print(S)

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

    
    ans = 0
    for x in range(1, N+1): 
        kaisuu = ceil( log( K / x, 2))
        
        tmp = 1/N
        for i in range(kaisuu):
            tmp *= 0.5
        ans += tmp 
    
    print(ans)
        

    
if __name__ == "__main__":
    solve()

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

print(ans)

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

print(ans)

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

b=1
S=0
a=0
m=0
for i in range(1,n+1):
    b=i
    for j in range(0,100000):
        if b>=k:
            m=j
            break
        else:
            b=b*2
            continue
    

    S=S+(1/(n*2**(m)))

print(S)

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

print(ans)

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):
n,k=map(int,input().split())
ans=0
for i in range(1,n+1):
    count=0
    while True:
        if i>=k:
            break
        i=i*2
        count+=1
    ans+=1/n*((1/2)**count)

print(ans)

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

print(ans)

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):
a=input().split()
a=list(map(int,a))
ini=a[0]
obj=a[1]
poss=0
i=1
divini=1
pot=0
posini=i/ini
while i<=ini:
  pot=0
  divini=i
  if divini>=obj:
    poss=poss+(1/ini)
  else:  
    while divini<obj:
      divini=divini*2
      pot+=1
    pg=(1/2)**pot
    poss=poss+(pg*posini)
  i+=1  
print(poss)

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

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

Solution (Python):
import numpy as np
 
N, K = map(int, input().split())
 
def get_x(n, K):
    if n >= K:
        return 0
    else:
        x_raw = np.log2(K) - np.log2(n)
        return np.ceil(x_raw)

def get_prob(n, K):
    x = get_x(n, K)
    if x == 0:
        return 1
    else:
        return (1/2)**x
    
ans = np.mean([get_prob(n, K) for n in range(1, N+1)], dtype=np.float64)
 
print('{0:.12f}'.format(ans))

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

print(ans)

Solution (Python):


import math

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

sum = 0
list = []
for n in range(1,N+1):
    if n < K:
        x = abs(math.log2(K/n))
        x_ceil = math.ceil(x)
        sum += pow(0.5, x_ceil)/N
    else:
        x_ceil = 1
        sum += 1/N

print(sum)

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

Solution (Python):
import numpy as np
 
N, K = map(int, input().split())
 
def get_x(n, K):
    if n >= K:
        return 0
    else:
        x_raw = np.log2(K) - np.log2(n)
        return np.ceil(x_raw)

def get_prob(n, K):
    x = get_x(n, K)
    if x == 0:
        return 1
    else:
        return (1/2)**x
    
ans = np.mean([get_prob(n, K) for n in range(1, N+1)], dtype=np.float64)
 
print('{0:.12f}'.format(ans))

Solution (Python):


import math

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

sum = 0
list = []
for n in range(1,N+1):
    if n < K:
        x = abs(math.log2(K/n))
        x_ceil = math.ceil(x)
        sum += pow(0.5, x_ceil)/N
    else:
        x_ceil = 1
        sum += 1/N

print(sum)

Solution (Python):
import math


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

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

X = [0] * N

for i in range(1,N+1):
    j = i
    tmp = 1

    while(j<K):
        j *= 2
        tmp /= 2

    X[i-1] = tmp

print(sum(X) / N)

Solution (Python):

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

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