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:
def main():
    n, k = map(int, input().split())

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
from math import log2, ceil
from collections import defaultdict

input = sys.stdin.readline

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

d = defaultdict(int)


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

    if die < K:
        d[ceil( log2( K/die ) )] += 1

    else:
        d[0] += 1

print(d)

cumulative = 0

for power in d:
    current = d[power]
    for _ in range(power):
        current /= 2

    cumulative += current

# print('{:.10f}'.format(cumulative / N))

print(cumulative / N)

Submission status: Wrong Answer

Solution code:
import math
N,K = map(int,input().split())
ans = 0
for i in range(1,N+1):
  X = K / i
  Y = math.log(X,2)
  Y_int = int(Y) + 1
  Z = 1 / N * (0.5 ** Y_int)
  ans += Z
print(ans)

Submission status: Wrong Answer

Solution code:
nk = input().split()
res = 0
for i in range(int(nk[0])):
    thisRes = 1 / int(nk[0])
    deme = i + 1
    while(1):
        thisRes /= 2
        deme *= 2
        if(deme >= int(nk[1])):
            break
    res += thisRes
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

win_ratio = 0
nn = n
for saikoro in range(1,n+1):
    nn = saikoro
    coin_cnt = 0
    while True:
        if nn  > k:
            break
        nn = nn * 2
        coin_cnt += 1
    win_ratio += (1/n) * (1/(pow(2, coin_cnt)))

print(win_ratio)

Submission status: Wrong Answer

Solution code:
import math
N, K = map(int, input().split())
total = 0
if K == 1:
    total = 1
else:
    for i in range(1, N+1):
        if K <= i:
            total += 1/N
        else:
            x = math.ceil((math.log(K) - math.log(i))/(math.log(2)))
            total += (1/N) * (1/(2**x))
print(total)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
import math
N ,K=map(int ,raw_input().split())

C = []
for i in range(N):
    C.append(int(math.ceil(np.log2(K)-np.log2(i+1))))
P = 0.0
C.sort()
k =C[0]
t = 0
p = 1.0
for n in C:
    t +=1
    if k != n:
        p=p/2
        P+=p*t
        t = 0        
print (P/N)

Submission status: Wrong Answer

Solution code:
import math
N,K = [int(x) for x in input().split()]
ans = 0
lk = math.log(K)
l2 = math.log(2)
for i in range(1,N+1):
    if(i>=K):
        ans+=1
        continue
    else:
        l = (lk-math.log(i))/l2
        if(not int(l)==l):
            l = int(l)+1
        else: l = int(l)
        ans += (0.5**l)
print(ans/N)

Submission status: Wrong Answer

Solution code:
import sys
import math
input = sys.stdin.readline

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

for saikoro in range(1, n + 1):
    if(saikoro < k):
        kaisu = math.ceil(math.log2(k / saikoro))
        kakuritu += 1 / (n * 2 ** kaisu)

print(kakuritu)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math


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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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

Submission status: Wrong Answer

Solution code:
import sys
import math

a = []
for l in sys.stdin:
    a.append(l)

_input = a[0]

n = int(_input.split()[0])
k = int(_input.split()[1])

each_result = max(n-k+1, 0) * (1/n)

for each_n in range(1, min(n+1, k)):
    each_time = int(math.log2(k/each_n)) + 1
    each_result += 1/n * (1/2) ** each_time

print(each_result)

Submission status: Wrong Answer

Solution code:
import math

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


kakuritsu = []
for x in range(1, N + 1):
    kaisu = math.ceil(math.log(10 / x, 2))
    if kaisu < 0:
        kaisu = 0
    kakuritsu.append(1 / N * pow(0.5, kaisu))

print(sum(kakuritsu))

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
N, K = map(int, input().split())
total = 0
for i in range(1, N+1):
    if K <= i:
        total += 1/N
    else:
        x = math.ceil((math.log(K) - math.log(i))/(math.log(2)))
        total += (1/N) * (1/(2**x))
print(total)

Submission status: Wrong Answer

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

ret = 0

for i in range(N):
    if (i + 1) < K:
        ret += (1.0 / N) * (0.5 ** (math.floor(math.log2(K / (i+1))) + 1))
    else:
        ret += (1.0 / N)
print(ret)

Submission status: Wrong Answer

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

l=[]
for i in range(1,N+1):
    n=0
    while i <= K:
        i *= 2
        n+=1
    l.append(1/N * (1/2)**n)

print(str(sum(l))[:14])

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
from string import ascii_uppercase
import sys, bisect, math
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N, K = read_int()

def solve():
    ans = 0.0
    # 2のべき乗のリスト
    l = []
    i = 1
    while i < K:
        l.append(i)
        i *= 2

    over = 0
    for i in range(1, N + 1):
        b = K // i
        if i >= K:
            ans += 1 / N
            over += 1
            continue
        p = bisect.bisect_right(l, b)
        ans += 1 / (N * (2 ** p))
    # ans += over / N

    return ans

if __name__ == "__main__":
    print(solve())

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(N):
    a = i + 1
    times = math.ceil(math.log2(K / a))
    prob += 1 / N * (1 / 2) ** times
print(prob)

Submission status: Wrong Answer

Solution code:
def solve(N, K):
    b = 1 / N
    poss = [b for _ in range(N + 1)]
    for n in range(16):
        for i in range(N + 1):
            if i == 0:
                continue
            if (i << n) < K <= (i << n + 1):
                poss[i] = b * (0.5 ** (n + 1))
    return "{:1.12f}".format(sum(poss[1:]))

if __name__ == "__main__":
    N, K = tuple(map(int, input().split(" ")))
    print(solve(N, K))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
ans = 0
for i in range(1, n + 1):
    digit_number_difference = len(str(bin(k))) - len(str(bin(i)))
    if digit_number_difference < 0:
        ans += 1/n
    elif k > i * 2 ** digit_number_difference:
        digit_number_difference += 1
        ans += (1/n) * (1/2)**digit_number_difference
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = 100000
K = 5

ans = 0
for i in range(1,N+1):
    x = np.log2((K-1)/i)
    if x < 0:
        ans += 1
    else:
        x = np.floor(x) + 1
        ans += (1/2)**x
        
ans /= N
print(ans)

Submission status: Wrong Answer

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

kakuritu = 0

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

print(kakuritu)

Submission status: Wrong Answer

Solution code:
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()
from collections import Counter

def main():
    N, K = LI()
    cnt = Counter()
    for i in range(1, min(K, N + 1)):
        cnt[(K // i).bit_length()] += 1
    for i in range(K, N + 1):
        cnt[0] += 1
    ma = max(x for x in cnt.keys())
    ans = 0
    for k, v in cnt.items():
        ans += v * (2 ** (ma - k))
    ans /= (N * 2 ** ma)
    return ans

print(main())

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
ret = 0.0
for i in range(1, N+1):
    c = (1/N)
    for j in range(K//2+1):
        if K <= i * (2**j):
            ret += c * (1/2) ** j
            break
print(ret)

Submission status: Wrong Answer

Solution code:
import sys
import math
input = sys.stdin.readline

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

for saikoro in range(1, n + 1):
    kaisu = math.ceil(math.log2(k / saikoro))
    kakuritu += 1/(n*2**kaisu)
print(kakuritu)

Submission status: Wrong Answer

Solution code:
"""
サイコロの値が
1 < x <= K - 1 : 
k回勝ち続けないければいけない。x * 2^k <= K
つまり k <= log2(K/x)
これを満たすkはint(log2(K/x)) + 1
この確率は(1 / 2) ^ k

K <= x <= N : 
勝利(=1)
e2 = 1 / (N - K + 1)
"""
import numpy as np
s = input().split(" ")
s = [int(s[i]) for i in range(len(s))]
N = s[0]
K = s[1]

if K > N : 
    sum_p = 0
    for x in range(1 , N + 1) : 
        k = int(np.log2(K / x)) + 1
        sum_p += (1/2) ** k / N
    print(sum_p)
else : 
    sum_p = 0
    for x in range(1 , K) : 
        k = int(np.log2(K / x)) + 1
        sum_p += (1/2) ** k / N
    for x in range(K , N + 1) : 
        sum_p += 1 / N

    print(sum_p)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

ret = 0
for x in range(1, N + 1):
    ret += 0.5 ** math.ceil(math.log2(K / x))
print(ret / N)

Submission status: Wrong Answer

Solution code:
import sys
from math import ceil, log2
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
N, K = tuple(li())
total = 0
for i in range(1, N + 1):
    total += 2 ** -ceil(log2(K/i))
print(total/N)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

l=[]
for i in range(1,N+1):
    n=0
    while i < K:
        i *= 2
        n+=1
    l.append(1/N * (1/2)**n)

print(str(sum(l))[:14])

Submission status: Wrong Answer

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

p = 0.0

if K <= N:
    p += (N-K)/N

for init_n in range(1, min([K, N+1])):
    p += 1/N * ((1/2)**math.ceil(math.log2(K/init_n)))

print(p)

Submission status: Wrong Answer

Solution code:
import math
N,K = map(int,input().split())
Z = []
Z = []
for i in range(1,N+1):
  a = i
  for m in range(math.ceil(math.sqrt(K))):
    a = a * 2
    if a >= K:
      break
  Z += [(1/3) * (0.5 ** (m + 1))]
sum = 0
for b in Z:
  sum += b
print(sum)

Submission status: Wrong Answer

Solution code:
import sys
import collections
from collections import Counter
from collections import deque
from collections import defaultdict
import itertools
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from itertools import takewhile
from itertools import compress
import functools
from functools import reduce
import math
####from math import gcd
####from math import inf
from math import ceil
from math import floor
##from math import log10
##from math import log2
##from math import log
from math import factorial
import re
from functools import lru_cache

# @lru_cache(maxsize=1000)

# MOD = 10 ** 9 + 7

# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]

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

ans = 0.0
for i in range(1, N + 1):
    score = i
    rate = 1.0 / N
    while score < 10:
        score *= 2
        rate /= 2
    ans += rate

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

rate = 0
for i in range(1,N+1):
    if i >= K:
        rate += (1/N)
    else:
        count = int(math.log2((K/i)))+1
        rate += (1/N) * ((1/2)**count)

print(rate)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

"""                         
Beautiful is better than ugly.
    Explicit is better than implicit.
Simple is better than complex.
    Complex is better than complicated.
Flat is better than nested.
    Sparse is better than dense.
                    
    * Readability counts *

 // Author : raj1307 - Raj Singh
 // Date   : 19.05.19

"""

from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().strip().split(" "))
def li(): return list(mi())

def dmain():
    sys.setrecursionlimit(100000000)
    threading.stack_size(40960000)
    thread = threading.Thread(target=main)
    thread.start()
    
#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
#from math import ceil,floor,log,sqrt,factorial,pow,pi
#from bisect import bisect_left,bisect_right
#from decimal import *,threading

abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod,MOD=1000000007,998244353
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]
def getKey(item): return item[0] 
def sort2(l):return sorted(l, key=getKey)
def d2(n,m,num):return [[num for x in range(m)] for y in range(n)]
def isPowerOfTwo (x): return (x and (not(x & (x - 1))) )
def decimalToBinary(n): return bin(n).replace("0b","")
def ntl(n):return [int(i) for i in str(n)]

def powerMod(x,y,p):
    res = 1
    x %= p
    while y > 0:
        if y&1:
            res = (res*x)%p
        y = y>>1
        x = (x*x)%p1
    return res

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x
    
def isPrime(n) : # Check Prime Number or not 
    if (n <= 1) : return False
    if (n <= 3) : return True
    if (n % 2 == 0 or n % 3 == 0) : return False
    i = 5
    while(i * i <= n) : 
        if (n % i == 0 or n % (i + 2) == 0) : 
            return False
        i = i + 6
    return True


# For getting input from input.txt file 
#sys.stdin = open('input.txt', 'r')  
  
# Printing the Output to output.txt file 
#sys.stdout = open('output.txt', 'w') 

def main():
    
    
    n,k=mi()
    prob=0
    for i in range(1,n+1):
        a=i
        c=0
        while(a<=k):
            a*=2
            c+=1
        prob+=(1/n)*((1/2)**c)
        
    print(prob)
            
            
            
            
                
    
    
    
    




# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        if self.buffer.tell():
            return self.buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip(b"\r\n")

# endregion

if __name__ == "__main__":
    main()
    #dmain()

Submission status: Wrong Answer

Solution code:
from math import log

n,k = (int(num) for num in input().split())
p = 1/n
ans = 0.0

def isPower(n):
    if n == 2 or n==1:
        return True
    elif n%2 == 1 or n%1 != 0:
        return False
    else:
        isPower(n//2)
    

if n >= k:
    ans += p * (n-k+1)
    for i in range(1,k):
        if isPower(k/i):
            ans += p*(1/2)**(int(log(k/i,2)))
        else:
            ans += p*(1/2)**(int(log(k/i,2))+1)
        
else:
    for i in range(1,k):
        if isPower(k/i):
            ans += p*(1/2)**(int(log(k/i,2)))
        else:
            ans += p*(1/2)**(int(log(k/i,2))+1)
        
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N,K = [int(x) for x in input().split()]
ans = 0
n = 1/N
lk = math.log(K)
l2 = math.log(2)
for i in range(1,N+1):
    if(i>=K):
        ans+=n
        continue
    else:
        l = (lk-math.log(i))/l2
        if(not int(l)==l):
            l = int(l)+1
        else: l = int(l)
        ans += n*(0.5**l)
print(ans)

Submission status: Wrong Answer

Solution code:
# AtCoder Beginner Contest 126
# https://atcoder.jp/contests/abc126
import sys
#import numpy as np

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, K = i2nn()
    ans = max((N - K + 1) / N, 0)
    n = min(N, K - 1)
    k = K
    r = 1.0
    while True:
        if n <= 0:
            break
        k *= 0.5
        r *= 0.5
        d = n - int(k)
        if d > 0:
            ans += (d / N) * r
            n -= d
    print(ans)

main()

Submission status: Wrong Answer

Solution code:
a,b=tuple(map(int,input().split()))
cnt=0
for i in range(2,a+2):
    cnt+=(1/2)**i*(1/a)
print(cnt)

Submission status: Wrong Answer

Solution code:
from math import log

n,k = (int(num) for num in input().split())
p = 1/n
ans = 0.0

def isPower(n):
    if n == 2:
        return True
    elif n%2 == 1 or n%1 != 0:
        return False
    else:
        isPower(n//2)
    

if n >= k:
    ans += p * (n-k+1)
    for i in range(1,k):
        if isPower(k/i):
            ans += p*(1/2)**(int(log(k/i,2)))
        else:
            ans += p*(1/2)**(int(log(k/i,2))+1)
        
else:
    for i in range(1,k):
        if isPower(k/i):
            ans += p*(1/2)**(int(log(k/i,2)))
        else:
            ans += p*(1/2)**(int(log(k/i,2))+1)
        
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

print(sum(map(lambda i: 0.5 ** (math.ceil(math.log2(k/i))), list(range(1, n+1)))) / n)

Submission status: Wrong Answer

Solution code:
import sys
import math

a = []
for l in sys.stdin:
    a.append(l)

_input = a[0]

n = int(_input.split()[0])
k = int(_input.split()[1])

each_result = 0
for each_n in range(1, n+1):
    each_time = int(math.log2(k/each_n)) + 1
    each_result += 1/n * (1/2) ** each_time

print(each_result)

Submission status: Wrong Answer

Solution code:
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()
from collections import Counter

def main():
    N, K = LI()
    cnt = Counter()
    for i in range(1, min(K, N + 1)):
        cnt[(K // i).bit_length()] += 1
    for i in range(K, N + 1):
        cnt[0] += 1
    ans = 0
    for k, v in cnt.items():
        ans += v * (0.5 ** k)
    ans /= N
    return ans

print(main())

Submission status: Wrong Answer

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

cnt = 0
while 2 ** cnt < K:
    cnt += 1

print(cnt)
res = 0
for i in range(1, N + 1):
    while i * (2 ** cnt) >= K and cnt >= 0:
        cnt -= 1
    cnt += 1
    res += 1 / ((2 ** cnt) * N)

print("{:.12g}".format(res))

Submission status: Wrong Answer

Solution code:
import math
n, k = map(int, input().split())
possibility = 0
# i.サイコロでK点以上になる
if(n>=k):
    possibility += (n-k+1)/n
# ii.サイコロでl点(l<k)となったとき->l*2^i>=kとなる最小のiについて、1/(2^i)が確率になる.これを全(l<k)について考える.
# 2^i>=k/l ->i = [log_2(k/l)]([]は天井関数)
for l in range(1, min(n+1, k)):
    i = math.ceil(math.log2(k/l))
    possibility += (1/n) * (1/(2**i))
    print("{} {}".format(l, i))
print(possibility)

Submission status: Wrong Answer

Solution code:
import sys
import math

a = []
for l in sys.stdin:
    a.append(l)

_input = a[0]

n = int(_input.split()[0])
k = int(_input.split()[1])

each_result = 0
for each_n in range(1, n+1):
    each_time = int(math.log2(k/each_n)) + 1
    each_result += 1/n + (1/2) ** each_time

print(each_result)

Submission status: Wrong Answer

Solution code:
import math
[n,k] = [int(i) for i in input().split()]
a = 0
if n <= k:
    for i in range(1,n+1):
        a += (1/n) * (1/2) **  math.ceil(math.log((k // i),2))
else:
    a = 0
print(a)

Submission status: Wrong Answer

Solution code:
from math import log
n,k = map(int,input().split())
ans = 0
for i in range(1,n+1):
    if i >= k:
        ans += 1
    else:
        m = (int(log(k/i,2))+1)
        ans += 0.5**m
    #if ans > 1:
        #print(i,ans)
        #exit()
ans *= 1/n
print(ans)

Submission status: Wrong Answer

Solution code:
def solve(N, K):
    b = 1 / N
    poss = [b for _ in range(N + 1)]
    poss[0] = 0
    for n in range(15):
        for i, b in enumerate(poss):
            if i == 0:
                continue
            if (i << n) < K <= (i << n + 1):
                poss[i] = b * (0.5 ** (n + 1))
    return "{:.012}".format(sum(poss[1:]))

if __name__ == "__main__":
    N, K = tuple(map(int, input().split(" ")))
    print(solve(N, K))

Submission status: Wrong Answer

Solution code:
from math import log

n,k = (int(num) for num in input().split())
p = 1/n
ans = 0.0

if n >= k:
    ans += p * (n-k+1)
    for i in range(1,k):
        ans += p*(1/2)**(int(log(k/i,2))+1)
        
else:
    for i in range(1,n+1):
        ans += p*(1/2)**(int(log(k/i,2))+1)
        
print(ans)

Submission status: Wrong Answer

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

cnt = 0
while 2 ** cnt < K:
    cnt += 1

print(cnt)
res = 0
for i in range(1, N + 1):
    while i * (2 ** cnt) >= K and cnt >= 0:
        cnt -= 1
    cnt += 1
    res += 1 / ((2 ** cnt) * N)

print(res)

Submission status: Wrong Answer

Solution code:
def solve(N, K):
    p = 0
    for i in range(1, N + 1):
        prob = 1 / 3
        point = i
        while point < K:
            point = point * 2
            prob = prob / 2
        p += prob
    return p


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

Submission status: Wrong Answer

Solution code:
from math import log,ceil
def solve():
    N,K = map(int, input().split())
    if N == 1 and K != 1:
        print("0")
        exit()

    ans = 0
    now2beki = 1
    for x in range(1, N+1): # xは初期値
        while x > now2beki * 2:
            now2beki *= 2

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

    
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(1,min(n+1,k)):
    cnt = 0
    tmp = i
    while tmp<k:
        tmp<<=1
        cnt+=1 
    print(cnt)
    res += 1.0/(n*(2**cnt))
if n>=k:
    res+=(n-k+1)/n
print(res)

Submission status: Wrong Answer

Solution code:
from math import log, ceil
N, K = [int(n) for n in input().split()]
ans = 0
for i in range(1, N+1):
    tmpans = ceil(log(K/i,2))
    # print(i, tmpans)
    ans += 1/N * (1/2)**tmpans
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import math

def solve(N: int, K: int):
    p = 0
    for i in range(1, N+1):
        if i < K:
            kaisu = int(math.log2(K / i)) + 1
            p += (1 / N) * (0.5) ** kaisu
        else:
            p += (1 / N)
    print(p)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

for i in range(1, n+1):
    c = math.log(k/i, 2)
    c = math.ceil(c)
    ans += pow(2, -c) / n

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7
BN = 2 ** 30

N, K = map(int, raw_input().split())
ans = 0
for i in range(1, N + 1):
    num = i
    S = BN
    while num < K:
        num *= 2
        S /= 2
    ans += S
if ans == BN * N:
    print 1
else:
    print "0." + str(ans * 10 ** 15 / (BN * N))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7
BN = 2 ** 30

N, K = map(int, raw_input().split())
ans = 0
for i in range(1, N + 1):
    num = i
    S = BN
    while num < K:
        num *= 2
        S /= 2
    ans += S
print "0." + str(ans * 10 ** 15 / (BN * N))

Submission status: Wrong Answer

Solution code:
import sys
import math
sys.setrecursionlimit(10**6)
from collections import defaultdict

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

Submission status: Time Limit Exceeded

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

def count(k,i):
    cnt=0
    while k>i:
        i**=2
        cnt+=1
    return cnt

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

Submission status: Time Limit Exceeded

Solution code:
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from itertools import (
    accumulate, combinations, combinations_with_replacement, groupby,
    permutations, product)
from math import (
    acos, asin, atan, ceil, cos, degrees, factorial, hypot, log2, pi, radians,
    sin, sqrt, tan)
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits


def inp():
    return(int(input()))


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


def instr():
    s = input()
    return(list(s[:len(s)]))


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


n, k = invr()
res = Decimal(0)
for i in range(1, n+1):
    if i >= (k-1):
        res += Decimal(1/n)
    else:
        x = int(ceil(log2((k)/i)))
        res += Decimal((1/n) * (1/2)**x)
print(res)