結果

問題 No.1742 Binary Indexed Train
ユーザー 👑 rin204rin204
提出日時 2022-01-23 08:08:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 384 ms / 3,000 ms
コード長 281 bytes
コンパイル時間 478 ms
コンパイル使用メモリ 87,116 KB
実行使用メモリ 77,924 KB
最終ジャッジ日時 2023-08-19 11:17:22
合計ジャッジ時間 14,009 ms
ジャッジサーバーID
(参考情報)
judge9 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
70,960 KB
testcase_01 AC 60 ms
71,048 KB
testcase_02 AC 62 ms
71,272 KB
testcase_03 AC 314 ms
77,300 KB
testcase_04 AC 318 ms
77,148 KB
testcase_05 AC 317 ms
77,164 KB
testcase_06 AC 288 ms
77,924 KB
testcase_07 AC 280 ms
77,328 KB
testcase_08 AC 377 ms
77,240 KB
testcase_09 AC 363 ms
77,228 KB
testcase_10 AC 360 ms
77,192 KB
testcase_11 AC 375 ms
77,140 KB
testcase_12 AC 384 ms
77,204 KB
testcase_13 AC 301 ms
77,104 KB
testcase_14 AC 305 ms
77,196 KB
testcase_15 AC 145 ms
77,056 KB
testcase_16 AC 126 ms
77,260 KB
testcase_17 AC 297 ms
77,144 KB
testcase_18 AC 273 ms
77,052 KB
testcase_19 AC 198 ms
77,244 KB
testcase_20 AC 98 ms
76,652 KB
testcase_21 AC 170 ms
77,312 KB
testcase_22 AC 300 ms
77,128 KB
testcase_23 AC 96 ms
76,428 KB
testcase_24 AC 87 ms
76,380 KB
testcase_25 AC 226 ms
77,208 KB
testcase_26 AC 218 ms
77,256 KB
testcase_27 AC 228 ms
77,260 KB
testcase_28 AC 106 ms
77,204 KB
testcase_29 AC 282 ms
77,012 KB
testcase_30 AC 157 ms
77,148 KB
testcase_31 AC 307 ms
77,124 KB
testcase_32 AC 159 ms
77,148 KB
testcase_33 AC 108 ms
77,240 KB
testcase_34 AC 226 ms
77,100 KB
権限があれば一括ダウンロードができます

ソースコード

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