結果
問題 | No.1869 Doubling? |
ユーザー |
|
提出日時 | 2022-03-11 22:20:03 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 41 ms / 2,000 ms |
コード長 | 458 bytes |
コンパイル時間 | 362 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 52,224 KB |
最終ジャッジ日時 | 2024-09-16 02:40:27 |
合計ジャッジ時間 | 3,227 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 |
ソースコード
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)