結果

問題 No.1742 Binary Indexed Train
ユーザー 👑 rin204
提出日時 2022-01-23 08:08:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 367 ms / 3,000 ms
コード長 281 bytes
コンパイル時間 593 ms
コンパイル使用メモリ 82,368 KB
実行使用メモリ 76,848 KB
最終ジャッジ日時 2024-11-29 03:25:29
合計ジャッジ時間 10,447 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

n, Q = map(int, input().split())
for _ in range(Q):
    s, t = map(int, input().split())
    ans = 0
    while s != t:
        if s & 1:
            s += 1
            ans += 1
        if t & 1:
            t -= 1
            ans += 1
        s >>= 1
        t >>= 1
    print(ans)
0