結果

問題 No.1869 Doubling?
ユーザー ShirotsumeShirotsume
提出日時 2022-03-11 21:54:10
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 369 bytes
コンパイル時間 394 ms
コンパイル使用メモリ 87,212 KB
実行使用メモリ 79,304 KB
最終ジャッジ日時 2023-10-14 07:00:23
合計ジャッジ時間 7,816 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
71,312 KB
testcase_01 AC 80 ms
71,308 KB
testcase_02 AC 80 ms
71,316 KB
testcase_03 AC 80 ms
71,264 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 WA -
testcase_07 RE -
testcase_08 AC 81 ms
71,272 KB
testcase_09 RE -
testcase_10 AC 78 ms
71,512 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 80 ms
71,288 KB
testcase_16 AC 78 ms
71,272 KB
testcase_17 AC 77 ms
71,232 KB
testcase_18 AC 78 ms
71,604 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 AC 77 ms
71,148 KB
testcase_25 AC 76 ms
71,332 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 79 ms
71,300 KB
testcase_29 AC 80 ms
71,396 KB
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 AC 80 ms
71,388 KB
testcase_34 AC 82 ms
71,524 KB
testcase_35 AC 78 ms
71,384 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 78 ms
71,520 KB
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 AC 79 ms
71,528 KB
testcase_44 RE -
testcase_45 AC 76 ms
71,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int,input().split())
if m == 1:
    print(n)
    exit()
maxi = 0
for v in range(m):
    if 2 ** (v + 1) > m:
        maxi = v + 1
        break

now = 2 ** maxi - m


s = bin(now)[2:]
ans = [2]
for i in range(maxi - 1):
    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