結果

問題 No.1742 Binary Indexed Train
ユーザー wolgnikwolgnik
提出日時 2021-11-12 22:11:02
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 296 bytes
コンパイル時間 444 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 153,616 KB
最終ジャッジ日時 2024-11-25 19:01:38
合計ジャッジ時間 68,032 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 TLE * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
N, Q = map(int, input().split())
for _ in range(Q):
  s, t = map(int, input().split())
  res = 0

  while s < t:
    for i in range(N, -1, -1):
      if s % pow(2, i) == 0 and s + pow(2, i) <= t:
        s += pow(2, i)
        break
    res += 1
  print(res)
0