結果

問題 No.1742 Binary Indexed Train
ユーザー googol_S0googol_S0
提出日時 2021-11-12 21:52:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 461 ms / 3,000 ms
コード長 301 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 87,272 KB
実行使用メモリ 79,252 KB
最終ジャッジ日時 2023-08-17 01:04:40
合計ジャッジ時間 12,710 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,364 KB
testcase_01 AC 69 ms
71,428 KB
testcase_02 AC 68 ms
71,604 KB
testcase_03 AC 394 ms
78,908 KB
testcase_04 AC 395 ms
78,588 KB
testcase_05 AC 397 ms
78,924 KB
testcase_06 AC 344 ms
79,252 KB
testcase_07 AC 341 ms
79,028 KB
testcase_08 AC 455 ms
78,880 KB
testcase_09 AC 458 ms
78,876 KB
testcase_10 AC 452 ms
79,000 KB
testcase_11 AC 461 ms
78,736 KB
testcase_12 AC 450 ms
78,852 KB
testcase_13 AC 349 ms
78,548 KB
testcase_14 AC 357 ms
78,820 KB
testcase_15 AC 201 ms
78,624 KB
testcase_16 AC 175 ms
78,532 KB
testcase_17 AC 366 ms
78,760 KB
testcase_18 AC 349 ms
78,860 KB
testcase_19 AC 259 ms
78,692 KB
testcase_20 AC 145 ms
79,016 KB
testcase_21 AC 215 ms
78,764 KB
testcase_22 AC 365 ms
78,712 KB
testcase_23 AC 151 ms
78,988 KB
testcase_24 AC 130 ms
78,404 KB
testcase_25 AC 302 ms
79,172 KB
testcase_26 AC 271 ms
78,764 KB
testcase_27 AC 285 ms
78,868 KB
testcase_28 AC 155 ms
78,888 KB
testcase_29 AC 353 ms
78,868 KB
testcase_30 AC 221 ms
78,868 KB
testcase_31 AC 382 ms
78,624 KB
testcase_32 AC 220 ms
78,692 KB
testcase_33 AC 162 ms
78,784 KB
testcase_34 AC 286 ms
78,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def query(l,r):
  x,y=l,r
  z=(1<<N)-1
  r=0
  while True:
    if x==y:
      return r
    if x&1:
      x+=1
      r+=1
    if y&1:
      r+=1
    if z==0:
      return r
    x>>=1
    y>>=1
    z>>=1

N,Q=map(int,input().split())
for i in range(Q):
  a,b=map(int,input().split())
  print(query(a,b))
0