結果

問題 No.1742 Binary Indexed Train
ユーザー wolgnikwolgnik
提出日時 2021-11-12 22:35:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,742 ms / 3,000 ms
コード長 391 bytes
コンパイル時間 518 ms
コンパイル使用メモリ 87,192 KB
実行使用メモリ 78,324 KB
最終ジャッジ日時 2023-08-17 02:43:56
合計ジャッジ時間 24,698 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,456 KB
testcase_01 AC 70 ms
71,460 KB
testcase_02 AC 70 ms
71,420 KB
testcase_03 AC 1,653 ms
77,564 KB
testcase_04 AC 1,653 ms
77,600 KB
testcase_05 AC 1,742 ms
77,608 KB
testcase_06 AC 126 ms
77,976 KB
testcase_07 AC 129 ms
78,324 KB
testcase_08 AC 1,094 ms
77,880 KB
testcase_09 AC 1,030 ms
77,976 KB
testcase_10 AC 1,046 ms
77,940 KB
testcase_11 AC 1,042 ms
77,808 KB
testcase_12 AC 1,046 ms
77,948 KB
testcase_13 AC 1,672 ms
77,712 KB
testcase_14 AC 1,706 ms
77,308 KB
testcase_15 AC 180 ms
77,612 KB
testcase_16 AC 218 ms
77,420 KB
testcase_17 AC 286 ms
77,764 KB
testcase_18 AC 318 ms
77,808 KB
testcase_19 AC 143 ms
77,564 KB
testcase_20 AC 95 ms
76,812 KB
testcase_21 AC 184 ms
77,612 KB
testcase_22 AC 360 ms
77,572 KB
testcase_23 AC 112 ms
77,008 KB
testcase_24 AC 94 ms
77,012 KB
testcase_25 AC 541 ms
77,748 KB
testcase_26 AC 165 ms
77,628 KB
testcase_27 AC 471 ms
77,608 KB
testcase_28 AC 103 ms
76,808 KB
testcase_29 AC 463 ms
77,644 KB
testcase_30 AC 567 ms
77,220 KB
testcase_31 AC 1,567 ms
77,672 KB
testcase_32 AC 575 ms
77,392 KB
testcase_33 AC 245 ms
76,860 KB
testcase_34 AC 983 ms
77,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

table = [1 << i for i in range(N + 1)]

for _ in range(Q):
  s, t = map(int, input().split())
  res = 0

  while s < t:
    ok = 0
    ng = N + 1
    while ng - ok > 1:
      m = (ok + ng) // 2
      x = table[m]
      if s % x == 0 and s + x <= t: ok = m
      else: ng = m
    s += table[ok]
    res += 1
  print(res)
0