Submission #3747754


Source Code Expand

n,x = list(map(int,input().split()))
a = [0 for i in range(n+1)]
a[0] = 1
su = [0 for i in range(n+1)]
su[0] = 1
for i in range(1,n+1):
    a[i] = a[i-1]*2 + 1
    su[i] = su[i-1]*2 + 3

ans = 0
i = n
jouken = False
while True:
    if i == 0:
        if x ==1:
            ans += 1
        break
    if x==1:
        break
    if x == su[i]:
        ans+=a[i]
        break
    if x == int(su[i]/2) +1:
        ans += a[i-1] +1
        break
    elif x < int(su[i]/2)+1:
        i -= 1
        x -= 1
    elif x > int(su[i]/2)+1:
        i -= 1
        ans += a[i]+1
        x -= su[i]
        x -= 2

print(ans)

Submission Info

Submission Time
Task D - Christmas
User yharu63
Language Python (3.4.3)
Score 400
Code Size 646 Byte
Status AC
Exec Time 17 ms
Memory 3064 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 16
Set Name Test Cases
Sample a01, a02, a03
All a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16
Case Name Status Exec Time Memory
a01 AC 17 ms 3064 KB
a02 AC 17 ms 3064 KB
a03 AC 17 ms 3064 KB
b04 AC 17 ms 3064 KB
b05 AC 17 ms 3064 KB
b06 AC 17 ms 3064 KB
b07 AC 17 ms 3064 KB
b08 AC 17 ms 3064 KB
b09 AC 17 ms 3064 KB
b10 AC 17 ms 3064 KB
b11 AC 17 ms 3064 KB
b12 AC 17 ms 3064 KB
b13 AC 17 ms 3064 KB
b14 AC 17 ms 3064 KB
b15 AC 17 ms 3064 KB
b16 AC 17 ms 3064 KB