結果

問題 No.1869 Doubling?
ユーザー aaaaaaaaaa2230
提出日時 2022-03-11 21:51:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 332 bytes
コンパイル時間 198 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 52,096 KB
最終ジャッジ日時 2024-09-16 02:05:03
合計ジャッジ時間 3,299 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
ans = 1
now = 1
ok = True
for i in range(n-1):
    now *= 2
    if now > m:
        ok = False
        break
    ans += now
if ok:
    print(ans)
    exit()

ans = m
now = m
for i in range(n-1):
    now = (now+1)//2
    ans += now
    if now == 1:
        print(ans+(n-2-i))
        exit()

print(ans)
0