109202024-04-18 21:54:2442Akasztós tartópython3Accepted 100/100386ms13300 KiB
#from sys import stdin, stdout
#input=stdin.readline

mod=10**9+7

from math import log

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

    K-=1

    res=0
    
    for pow2 in range(N-1,-1,-1):
        if K<=0:
            break
        if pow2 <= log(K,2):
            res+=pow(2,N-1-pow2,mod)
            K-=2**pow2            

    print((res+1)%mod)
        
solv()
SubtaskSumTestVerdictTimeMemory
subtask120/20
1Accepted17ms11276 KiB
2Accepted18ms11628 KiB
3Accepted17ms11816 KiB
4Accepted17ms12196 KiB
5Accepted17ms12240 KiB
subtask220/20
1Accepted17ms11988 KiB
2Accepted17ms12592 KiB
3Accepted17ms12584 KiB
4Accepted17ms12536 KiB
5Accepted17ms12940 KiB
subtask360/60
1Accepted17ms13024 KiB
2Accepted17ms13064 KiB
3Accepted19ms12964 KiB
4Accepted39ms13300 KiB
5Accepted386ms13116 KiB