結果

問題 No.1742 Binary Indexed Train
ユーザー googol_S0googol_S0
提出日時 2021-11-12 21:52:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 430 ms / 3,000 ms
コード長 301 bytes
コンパイル時間 116 ms
コンパイル使用メモリ 82,584 KB
実行使用メモリ 77,696 KB
最終ジャッジ日時 2024-05-04 08:21:41
合計ジャッジ時間 10,055 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
51,968 KB
testcase_01 AC 33 ms
51,968 KB
testcase_02 AC 35 ms
52,008 KB
testcase_03 AC 427 ms
77,312 KB
testcase_04 AC 370 ms
77,440 KB
testcase_05 AC 374 ms
77,388 KB
testcase_06 AC 272 ms
76,788 KB
testcase_07 AC 273 ms
77,056 KB
testcase_08 AC 430 ms
77,440 KB
testcase_09 AC 424 ms
77,440 KB
testcase_10 AC 399 ms
77,056 KB
testcase_11 AC 388 ms
77,056 KB
testcase_12 AC 369 ms
77,056 KB
testcase_13 AC 283 ms
76,288 KB
testcase_14 AC 298 ms
76,604 KB
testcase_15 AC 156 ms
77,384 KB
testcase_16 AC 139 ms
76,928 KB
testcase_17 AC 297 ms
77,436 KB
testcase_18 AC 283 ms
77,440 KB
testcase_19 AC 208 ms
77,440 KB
testcase_20 AC 102 ms
77,128 KB
testcase_21 AC 164 ms
77,312 KB
testcase_22 AC 300 ms
77,172 KB
testcase_23 AC 106 ms
77,180 KB
testcase_24 AC 85 ms
76,928 KB
testcase_25 AC 238 ms
77,184 KB
testcase_26 AC 219 ms
77,440 KB
testcase_27 AC 226 ms
77,568 KB
testcase_28 AC 107 ms
76,996 KB
testcase_29 AC 289 ms
77,056 KB
testcase_30 AC 169 ms
77,696 KB
testcase_31 AC 324 ms
77,312 KB
testcase_32 AC 164 ms
77,184 KB
testcase_33 AC 121 ms
77,056 KB
testcase_34 AC 228 ms
77,312 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