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



Sample input:
3 10


Sample output:
0.145833333333

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 09:53:12 2019

@author: Owner
"""
import numpy as np
import sys
import collections
import scipy.misc
import math
from operator import itemgetter
import itertools
import copy
import bisect

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


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

x = list(map(int, input().split()))

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())

# 多次元配列の宣言（あとでintにすること。）（タプルにすること。）
dp = np.zeros((N+1, 4,4,4))
    
all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break
# 累積和
add = 1 # 問題によって決まる
res = 0
sums = [0]*(len(nums)+1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]
for i in range(0, len(nums), 2):
    left = i
    right = min(i+add, len(nums))
    tmp = sums[right] - sums[left]
    res = max(tmp, res)

#２分探索
li, ri = bisect.bisect_left(p_ac, l[i]-1), bisect.bisect_right(p_ac, r[i]-1)    

#ソート関数
org_list = [3, 1, 4, 5, 2]
new_list = sorted(org_list)
print(org_list)
print(new_list)
# [3, 1, 4, 5, 2]
# [1, 2, 3, 4, 5]

#Distance Transformation
    for h in range(0,H):
        for w in range(0,W):
            if h == 0 and w == 0:
                pass
            elif h == 0:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h-1][W-w]+1)
            elif w == 0:   
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1)
            else:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1, D[H-h-1][W-w]+1, D[H-h][W-w]+2)
            d_max = max(D[H-h-1][W-w-1], d_max)

"""
N, K = list(map(int, input().split()))
def main():
    p = 0.
    if K < N:
        p += float(N-K+1)/float(N)
    for n in range(1,min(K, N+1)):
        i = 1         
        while n*2**i<K:
            i+=1
        p += 1./float(N)*(1./2.)**(float(i)) 
            
    print(p)
                
                
                
            
            
                

    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 09:53:12 2019

@author: Owner
"""
import numpy as np
import sys
import collections
import scipy.misc
import math
from operator import itemgetter
import itertools
import copy
import bisect

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


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

x = list(map(int, input().split()))

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())

# 多次元配列の宣言（あとでintにすること。）（タプルにすること。）
dp = np.zeros((N+1, 4,4,4))
    
all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break
# 累積和
add = 1 # 問題によって決まる
res = 0
sums = [0]*(len(nums)+1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]
for i in range(0, len(nums), 2):
    left = i
    right = min(i+add, len(nums))
    tmp = sums[right] - sums[left]
    res = max(tmp, res)

#２分探索
li, ri = bisect.bisect_left(p_ac, l[i]-1), bisect.bisect_right(p_ac, r[i]-1)    

#ソート関数
org_list = [3, 1, 4, 5, 2]
new_list = sorted(org_list)
print(org_list)
print(new_list)
# [3, 1, 4, 5, 2]
# [1, 2, 3, 4, 5]

#Distance Transformation
    for h in range(0,H):
        for w in range(0,W):
            if h == 0 and w == 0:
                pass
            elif h == 0:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h-1][W-w]+1)
            elif w == 0:   
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1)
            else:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1, D[H-h-1][W-w]+1, D[H-h][W-w]+2)
            d_max = max(D[H-h-1][W-w-1], d_max)

"""
N, K = list(map(int, input().split()))
def main():
    p = 0.
    if K < N:
        p += float(N-K)/float(N)
    for n in range(1,min(K+1, N+1)):
        for i in range(1,2*K//N+1):
            if i >= math.log2(K/float(n)):
                p += 1./float(N)*(1./2.)**(float(i)) 
                break
    
    print(p)
                
                
                
            
            
                

    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import log2

def prob(num, dice, K):
	base  = 1/dice
	if num < K:
		times = int(log2(K/num))+1
		p = base * pow(0.5,times)
	else:
		p = base
	return p

def sum_prob(dice, K):
	probabilty = 0
	for i in range(1,int(dice+1)):
		probabilty += prob(i, dice, K)
	return probabilty


inputs = list(map(float,input().split(' ')))[:2]
dice = inputs[0]
K = inputs[1]
probabilty = sum_prob(dice, K)
print(probabilty)

Submission status: Wrong Answer

Solution code:
from math import log2

def prob(num, dice, K):
	times = int(log2(K/num) + 1)
	base  = 1/dice
	if times < 0:
		times = 0
	p = base * pow(0.5,times)
	return p

def sum_prob(dice, K):
	probabilty = 0
	for i in range(1,int(dice+1)):
		probabilty += prob(i, dice, K)
	return probabilty


inputs = list(map(float,input().split(' ')))[:2]
dice = inputs[0]
K = inputs[1]
probabilty = sum_prob(dice, K)
print(probabilty)

Submission status: Wrong Answer

Solution code:
from math import log2

def prob(num, dice, K):
	times = int(log2(K/num) + 1)
	base  = 1.0/dice
	if times < 0:
		times = 0
	p = base * pow(0.5,times)
	return p

def sum_prob(dice, K):
	probabilty = 0
	for i in range(1,dice+1):
		probabilty += prob(i, dice, K)
	return probabilty


inputs = list(map(int,input().split(' ')))[:2]
dice = inputs[0]
K = inputs[1]
probabilty = sum_prob(dice, K)
print(probabilty)

Submission status: Wrong Answer

Solution code:
from math import log2

def prob(num, dice, K):
	times = int(log2(K/num) + 1)
	base  = 1/dice
	if times < 0:
		times = 0
	p = base * pow(0.5,times)
	return p

def sum_prob(dice, K):
	probabilty = 0
	for i in range(1,dice+1):
		probabilty += prob(i, dice, K)
	return probabilty


inputs = list(map(int,input().split(' ')))[:2]
dice = inputs[0]
K = inputs[1]
probabilty = sum_prob(dice, K)
print(probabilty)

Submission status: Wrong Answer

Solution code:
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

Submission status: Wrong Answer

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

for i in range(1, n+1):
    tm = 0
    for p in range(0, 15):
        if i * (2**p) >= k:
            tm = p
            break
    d = (2**tm)
    sc = 1/(n*d)
    ttl += sc

print(ttl)

Submission status: Wrong Answer

Solution code:
import math
n,k = map(int, input().split())
p = 0
for i in range(1,min(n+1,k)):
    p += (1/n) * (1/2)**math.ceil(math.log(k/i,2))
p += (n-k+1)/n if n > k else 0
print("{:.12f}".format(p))

Submission status: Wrong Answer

Solution code:
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))))
    
ans / (N * 2 ** max_pow)

Submission status: Wrong Answer

Solution code:
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+1):
        ans += f(n, K) * 1/N
    ans += float(N-K+1)/N
    
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

s = 0
logK = math.log(k)
log2 = math.log(2)
for i in range(n):
    if k > i + 1:
        n_ = math.ceil((logK - math.log(i + 1)) / log2)
    else:
        n_ = 0
    s += math.pow(1/2, n_)
print(s / n)

Submission status: Wrong Answer

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

print(proba)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
proba = 0
if K == 1:
    print(1)
else:
    for n in range(0, N+1):
        for ii in range(17):
            if n * (2 ** ii) >= K:
                proba += (1 / N) * (2 ** (-ii))
                break
            
    print(proba)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
proba = 0
if K == 1:
    print(1)
else:
    for n in range(0, N+1):
        for ii in range(17):
            if n * (2 ** ii) >= K:
                proba += (1 / N) * (2 ** (-ii))
                break
            
print(proba)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

size = N

logK = math.log(K)
log2 = math.log(2)
log1_2 = math.log(1/2)
log1_N = math.log(1/N)

logPs = []
suffix = []
for n in [n+1 for n in range(N)]:
    # n*2**x >= K
    if K <= n:
        suffix.append(1/N)
        continue
    x = math.ceil((logK-math.log(n))/log2)
    #print(n, x)
    logP = x*log1_2 + log1_N
    logPs.append(logP)

print(sum([math.exp(x) for x in logPs] + suffix))

Submission status: Wrong Answer

Solution code:
import math, decimal

n, k = map(int,input().split())
per = 0
for i in range(1, n+1):
    x = math.ceil(math.sqrt(k/i)) if k > i else 0
    per += 1/(2**x)

print(per/n)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
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 = 0L
for i in range(1, N+1):
	sum += long(pow2(counter[1]-counter[i]))
dv = long(N)*long(pow2(counter[1]))
if sum == dv: print 1
else:
	sum *= 1000000000000
	print '0.'+str(sum/dv)

Submission status: Wrong Answer

Solution code:
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 = 0L
for i in range(1, N+1):
	sum += long(pow2(counter[1]-counter[i]))
dv = long(N)*long(pow2(counter[1]))
if sum == dv: print 1
else:
	sum *= 10000000000
	print '0.'+str(sum/dv)

Submission status: Wrong Answer

Solution code:
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 = 0L
for i in range(1, N+1):
	sum += long(pow2(counter[1]-counter[i]))
sum *= 10000000000
dv = long(N)*long(pow2(counter[1]))

print '0.'+str(sum/dv)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
import sys
import math

def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    
    l = []
    for i in range(N):
        j = i + 1
        cnt = 1
        while True:
            j = j * 2
            
            if j >= K:
                l.append(cnt)
                break
            else:
                cnt = cnt + 1
                
    ans = [1 / (N * 2 ** c) for c in l]
    print(sum(ans))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
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/3*(1/2)**count
    probability_i.append(prob)
ans=0
for j in probability_i:
    ans+=j
if ans>1:
    ans=1
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
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/3*(1/2)**count
    probability_i.append(prob)
ans=0
for j in probability_i:
    ans+=j
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

#list =[0 for i in range(N)]
p = 0
for i in range(N):
    i = i+1
    b = 0
    while 1:
        if K <= i:
            #p += (1/3)*(1/2**b)
            p += 1/2**b
            break
        else:
            b += 1
            i = i*2

print(p/3)

Submission status: Wrong Answer

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

#list =[0 for i in range(N)]
p = 0
for i in range(N):
    i = i+1
    b = 0
    while 1:
        if K <= i:
            p += (1/3)*(1/2**b)
            break
        else:
            b += 1
            i = i*2

print(p)

Submission status: Wrong Answer

Solution code:
import random
N, K = map(int, input().split())
win = 0
lose = 0
ans = 0
for i in range(100000):
    point = random.randint(1, N)
    while 1:


        coin = random.randint(1, 2)
        if coin == 1:
            point *= 2
        else:
            point = 0

        if point >= K:
            win += 1
            break
        if point == 0:
            lose += 1
            break
ans = win / (lose + win)
print(ans)

Submission status: Wrong Answer

Solution code:
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) / n[0]

print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
result = 0
for i in range(1,n):
  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)

Submission status: Wrong Answer

Solution code:
import math

def power_two(n):
    return int(math.log(n, 2))+1

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

cointoss = []
for i in range(1,N+1):
    if i < K:
        cointoss.append(power_two(K//i))
    else:
        cointoss.append(0)

base = max(cointoss)
ue = 0
for x in cointoss:
    ue += 2 ** (base - x)

print(ue/(N * (2**base)))

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
  a = input().split()
  n = int(a[0])
  k = int(a[1])
  prev = 0
  now = 1
  min_nk = min(n,k)
  l = max(0,n-k)*1.0
  _sum = l*1.0/n
  flg = True
  while flg:
    if now >= min_nk:
      flg = False
    
    i = 0
    counter = now
    while counter < k:
      i += 1
      counter *= 2
    length = now - prev

    _sum += length*1.0/n*0.5**i
    prev = now
    now = min(n, k, now * 2)

  print(_sum)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
  a = input().split()
  n = int(a[0])
  k = int(a[1])
  prev = 0
  now = 1
  min_nk = min(n,k)
  l = max(0,n-k)*1.0
  _sum = l
  flg = True

  while flg:
    if now >= min_nk:
      flg = False
    i = 0
    counter = now
    while counter < k:
      i += 1
      counter *= 2
    length = now - prev

    _sum += length*0.5**i
    prev = now
    now = min(n, k, now * 2)

  print(_sum/n)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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 >= b:
		break;
	num = checkMultiNum(v+1, b)
	tmp = prob * 0.5**num
	res += tmp

print(res)

Submission status: Wrong Answer

Solution code:
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):
	if v >= b:
		break;
	num = checkMultiNum(v+1, b)
	tmp = prob * 0.5**num
	res += tmp

print(res)

Submission status: Wrong Answer

Solution code:
import math

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

p=0

for i in range(1,N+1):

    x=math.ceil((math.log10(K)-math.log10(i))/math.log10(2))

    p += (1.0/(2**x))

p = p / N

print(p)

Submission status: Wrong Answer

Solution code:
N, K = input().split()

N = int(N)
K = int(K)

prob = 0

for i in range(1, N+1):
    a = i
    b = 0
    while(True):
        a *= 2
        b += 1
        if(a >= K):
            break
#    print(prob)
    prob += 1 / N * ((1 / 2) ** b)
    if(K <= i):
        prob += (N-i) / N
        break

print(prob)

Submission status: Wrong Answer

Solution code:
N, K = input().split()

N = int(N)
K = int(K)

prob = 0

for i in range(1, N+1):
    a = i
    b = 0
    while(True):
        a *= 2
        b += 1
        if(a >= K):
            break
    print(prob)
    prob += 1 / N * ((1 / 2) ** b)
    if(K <= i):
        prob += (N-i) / N
        break

print(prob)

Submission status: Wrong Answer

Solution code:
N, K = input().split()

N = int(N)
K = int(K)

prob = 0

for i in range(1, N+1):
    a = i
    b = 0
    while(True):
        a *= 2
        b += 1
        if(a >= K):
            break

    if(K < i):
        prob += 1/N
    else:
        prob += 1 / N * ((1 / 2) ** b)

print(prob)

Submission status: Wrong Answer

Solution code:
N, K = input().split()

N = int(N)
K = int(K)

prob = 0

for i in range(1, N+1):
    a = i
    b = 0
    while(True):
        a *= 2
        b += 1
        if(a >= K):
            break
    prob += 1/N * ((1/2)**b)
    if(K < i):
        prob = 1-prob
        break

print(prob)

Submission status: Wrong Answer

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

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

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

'''
import math

def main():
	'''
	メイン関数
	'''
	# N面サイコロ, 判定K
	N, K = map(int, input().split())

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

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

	print(sum)



if __name__ == '__main__':
	main()

Submission status: Wrong Answer

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

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

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

'''
import math

def main():
	'''
	メイン関数
	'''
	# N面サイコロ, 判定K
	N, K = map(int, input().split())

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

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

	print(sum)

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

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

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

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

'''
import math

def main():
	'''
	メイン関数
	'''
	# N面サイコロ, 判定K
	N, K = map(int, input().split())

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

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

	print(sum)

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

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

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

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

'''
import math

def main():
	'''
	メイン関数
	'''
	# N面サイコロ, 判定K
	N, K = map(int, input().split())


	# 愚直
	sum  = 0
	for i in range(1,N+1):
		x = 0
		if i < K-1:
			x = math.ceil(math.log(K/i, 2))
		sum = sum + (1/N ) * (1/2) ** x  

	print(sum)

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
import math

# NとKの入力、Nはサイコロの面の数,Kは得点
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)
'''
# 1~Nまでのサイコロによるそれぞれの確率を算出
for num in range(1, n+1):

    x = int(math.log(k / num, 2)) + 1
    if x < 2:
        x = 0
    prob += (1 / n) * pow(1 / 2, x)

print(prob)

Submission status: Wrong Answer

Solution code:
import math

# NとKの入力、Nはサイコロの面の数,Kは得点
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)
'''
# 1~Nまでのサイコロによるそれぞれの確率を算出
for num in range(1, n+1):
    if num > k:
        prob += 1/n
    else:
        x = int(math.log(k / num, 2)) + 1
        prob += (1 / n) * pow(1 / 2, x)

print(prob)

Submission status: Wrong Answer

Solution code:
import math
N,K=[int(i) for i in input().split()]
res=0
for i in range(1,N+1):
  res+=0.5**(math.ceil(math.log2(K/i)))
print(res/N)

Submission status: Wrong Answer

Solution code:
from decimal import *

dp = [0] * 100000

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

n_count = n
p_count = 1
while n_count != 0:
    if k - 1 <= n_count:
        dp[0] += 1
    else:
        var = n_count
        for p in range(0, p_count):
            var = var * 2
        if k - 1 <= n_count:
            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 i == 0:
        ans += Decimal(1/n) * Decimal(d)
        continue
    elif d != 0:
        ans += (Decimal(1/n) * Decimal(1/2) ** Decimal(i)) * Decimal(d)

print("{0:.13f}".format(ans))

Submission status: Wrong Answer

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

div_list = [k/(2**i) for i in range(17)]
#div_list = filter(lambda x: x >= 1, div_list) 
n_list = [i+1 for i in range(n)]

def get_index(num_list,num):
    num_list.append(num)
    num_list.sort()
    index = num_list.index(num)
    del num_list[num_list.index(num)]
    return index

cal_list = []
for num in div_list:
    cal_list.append(get_index(n_list,num))

prev_index = n
answer = 0
for i in range(len(cal_list)):
    answer += (1/2)**i*len(n_list[cal_list[i]:prev_index])
    prev_index = cal_list[i]
print(answer/n)

Submission status: Wrong Answer

Solution code:
import random
n,k=map(int,input().split())
win=0
lose=0
a=0
while a<100 :
    count=random.randint(1,n)
    while 0<count<k:
        b=random.randint(1,2)
        if b==1:
            count*=2
        else:
            count=0
    if count>0:
        win+=1
    else:
        lose+=1
    a+=1
print(win/100)

Submission status: Wrong Answer

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

win_rate_sum = 0
for i in range(n):
    i += 1
    win_rate = 0
    if i >= k:
        win_rate = 1
    elif i * 2 >= k:
        win_rate = 0.5
    else:
        renzoku = int(math.log2(int(k/i))) + 1
        # print('i',i,'ren', renzoku)
        win_rate = math.pow((1/2), renzoku)
    # print(win_rate)
    win_rate_sum += win_rate
print(win_rate_sum/n)

Submission status: Wrong Answer

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

win_rate_sum = 0
for i in range(n):
    i += 1
    win_rate = 0
    if i >= k:
        win_rate = 1
    elif i * 2 >= k:
        win_rate = 0.5
    else:
        renzoku = int(math.log2(int(k/i))) + 1
        # print('ren', renzoku)
        win_rate = math.pow((1/2), renzoku)
    # print(win_rate)
    win_rate_sum += win_rate * 1/n
print(win_rate_sum)

Submission status: Wrong Answer

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

win_rate_sum = 0
for i in range(n):
    i += 1
    win_rate = 0
    if i >= k:
        win_rate = 1
    elif i * 2 >= k:
        win_rate = 0.5
    else:
        renzoku = int(math.log2(int(k/i))) + 1
        print('ren', renzoku)
        win_rate = math.pow((1/2), renzoku)
    # print(win_rate)
    win_rate_sum += win_rate * 1/n
print(win_rate_sum)

Submission status: Wrong Answer

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

result =0

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

print(result/N)

Submission status: Wrong Answer

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

result =0

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

print(result/N)

Submission status: Wrong Answer

Solution code:
a=input()
print(a)

Submission status: Wrong Answer

Solution code:
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)), range(n))
print(sum(p) / n)

Submission status: Wrong Answer

Solution code:
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)/N
print (l+m)

Submission status: Wrong Answer

Solution code:
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/N 
print (l+m)