結果

問題 No.1869 Doubling?
コンテスト
ユーザー wolgnik
提出日時 2022-03-11 21:48:07
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 253 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 150 ms
コンパイル使用メモリ 84,992 KB
実行使用メモリ 52,096 KB
最終ジャッジ日時 2026-04-05 05:50:06
合計ジャッジ時間 2,321 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = sys.stdin.readline
N, M = map(int, input().split())

m = M.bit_length() - 1
if N - 1 <= m:
  print(pow(2, N) - 1)
  exit(0)

res = 0
c = 0
while M > 1:
  res += M
  M += 1
  M >>= 1
  c += 1
  #print(M, c, res)
res += N - c
print(res)
0