結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,148 KB
testcase_01 AC 69 ms
71,408 KB
testcase_02 AC 69 ms
71,140 KB
testcase_03 AC 68 ms
71,316 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 70 ms
71,472 KB
testcase_09 WA -
testcase_10 AC 69 ms
71,408 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 70 ms
71,280 KB
testcase_16 AC 69 ms
71,192 KB
testcase_17 AC 70 ms
71,376 KB
testcase_18 AC 69 ms
71,676 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 69 ms
71,452 KB
testcase_25 AC 71 ms
71,404 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 69 ms
71,348 KB
testcase_29 AC 70 ms
71,168 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 69 ms
71,232 KB
testcase_34 AC 68 ms
71,432 KB
testcase_35 AC 70 ms
71,240 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 73 ms
71,404 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 70 ms
71,464 KB
testcase_44 WA -
testcase_45 AC 69 ms
71,368 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

now = 2 ** maxi - m


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)

0