結果

問題 No.1742 Binary Indexed Train
ユーザー aaaaaaaaaa2230
提出日時 2021-11-12 23:29:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 385 ms / 3,000 ms
コード長 305 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 76,544 KB
最終ジャッジ日時 2024-11-25 21:49:57
合計ジャッジ時間 9,779 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

n,q = map(int,input().split())

for i in range(q):
    s,t = map(int,input().split())
    s += 1<<n
    t += 1<<n
    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