結果

問題 No.1869 Doubling?
ユーザー ShirotsumeShirotsume
提出日時 2022-03-11 22:04:37
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 570 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 87,112 KB
実行使用メモリ 71,744 KB
最終ジャッジ日時 2023-10-14 07:14:03
合計ジャッジ時間 5,569 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,408 KB
testcase_01 AC 72 ms
71,584 KB
testcase_02 AC 71 ms
71,388 KB
testcase_03 AC 72 ms
71,648 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 71 ms
71,448 KB
testcase_07 WA -
testcase_08 AC 71 ms
71,272 KB
testcase_09 AC 73 ms
71,216 KB
testcase_10 AC 76 ms
71,372 KB
testcase_11 AC 75 ms
71,296 KB
testcase_12 AC 71 ms
71,412 KB
testcase_13 AC 71 ms
71,432 KB
testcase_14 AC 72 ms
71,340 KB
testcase_15 AC 70 ms
71,144 KB
testcase_16 AC 71 ms
71,320 KB
testcase_17 AC 71 ms
71,644 KB
testcase_18 AC 72 ms
71,148 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 73 ms
71,396 KB
testcase_25 AC 72 ms
71,452 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 71 ms
71,368 KB
testcase_29 AC 71 ms
71,420 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 72 ms
71,216 KB
testcase_34 AC 71 ms
71,304 KB
testcase_35 AC 72 ms
71,300 KB
testcase_36 AC 73 ms
71,328 KB
testcase_37 AC 72 ms
71,244 KB
testcase_38 AC 72 ms
71,256 KB
testcase_39 AC 72 ms
71,216 KB
testcase_40 AC 71 ms
71,276 KB
testcase_41 AC 70 ms
71,436 KB
testcase_42 WA -
testcase_43 AC 69 ms
71,380 KB
testcase_44 AC 71 ms
71,324 KB
testcase_45 AC 71 ms
71,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int,input().split())
if m == 1:
    print(n)
    exit()
maxi = 0
for v in range(m + 1000):
    if 2 ** (v + 1) >= m:
        maxi = v + 1
        break
if maxi >= n:
    ans = 2 ** n - 1
    print(ans)
    exit()
now = 2 ** maxi - m
if now != 0:
    s = bin(now)[2:]
    ans = [2]
    for i in range(len(s)):
        if s[i] == '1':
            ans.append(2 * ans[-1] - 1)
        else:
            ans.append(2 * ans[-1])
    l = n - len(s)
    print(sum(ans) + l - 1)
else:
    ans1 = 2 ** (maxi + 1) - 1
    ans2 = n - maxi - 1
    print(ans1 + ans2)
    
0