結果

問題 No.1869 Doubling?
ユーザー ShirotsumeShirotsume
提出日時 2022-03-11 22:20:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 458 bytes
コンパイル時間 1,322 ms
コンパイル使用メモリ 86,848 KB
実行使用メモリ 71,492 KB
最終ジャッジ日時 2023-10-14 07:32:43
合計ジャッジ時間 5,495 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,120 KB
testcase_01 AC 73 ms
71,300 KB
testcase_02 AC 73 ms
71,272 KB
testcase_03 AC 74 ms
71,404 KB
testcase_04 AC 74 ms
71,440 KB
testcase_05 AC 74 ms
71,492 KB
testcase_06 AC 74 ms
71,296 KB
testcase_07 AC 74 ms
71,124 KB
testcase_08 AC 74 ms
71,340 KB
testcase_09 AC 74 ms
71,140 KB
testcase_10 AC 73 ms
71,348 KB
testcase_11 AC 74 ms
71,256 KB
testcase_12 AC 74 ms
71,072 KB
testcase_13 AC 75 ms
71,272 KB
testcase_14 AC 73 ms
71,356 KB
testcase_15 AC 74 ms
71,124 KB
testcase_16 AC 75 ms
71,116 KB
testcase_17 AC 74 ms
71,072 KB
testcase_18 AC 73 ms
71,200 KB
testcase_19 AC 75 ms
71,272 KB
testcase_20 AC 72 ms
71,452 KB
testcase_21 AC 73 ms
71,076 KB
testcase_22 AC 75 ms
71,120 KB
testcase_23 AC 76 ms
71,276 KB
testcase_24 AC 74 ms
71,220 KB
testcase_25 AC 74 ms
71,272 KB
testcase_26 AC 72 ms
71,224 KB
testcase_27 AC 74 ms
71,220 KB
testcase_28 AC 72 ms
71,120 KB
testcase_29 AC 72 ms
71,220 KB
testcase_30 AC 73 ms
71,272 KB
testcase_31 AC 74 ms
71,416 KB
testcase_32 AC 74 ms
71,256 KB
testcase_33 AC 75 ms
71,348 KB
testcase_34 AC 75 ms
71,432 KB
testcase_35 AC 74 ms
71,124 KB
testcase_36 AC 76 ms
71,140 KB
testcase_37 AC 75 ms
71,368 KB
testcase_38 AC 74 ms
71,300 KB
testcase_39 AC 74 ms
71,272 KB
testcase_40 AC 75 ms
71,424 KB
testcase_41 AC 73 ms
71,228 KB
testcase_42 AC 73 ms
71,040 KB
testcase_43 AC 73 ms
71,308 KB
testcase_44 AC 73 ms
71,220 KB
testcase_45 AC 74 ms
70,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int,input().split())
maxi = 0
for i in range(1000):
    if 2 ** i >= m:
        maxi = i
        break
ans = 0
if maxi + 1 > n:
    ans = 2 ** n - 1
else:
    leng1 = maxi #2, 3, ...
    leng2 = n - leng1 #1, 1, ...
    now = 2 ** maxi - m
    a = [2]
    for i in range(leng1 - 2, -1, -1):
        if 1 & (now >> i):
            a.append(2 * a[-1] - 1)
        else:
            a.append(2 * a[-1])
    ans = sum(a[:leng1]) + leng2
print(ans)



0