結果

問題 No.1742 Binary Indexed Train
ユーザー puznekopuzneko
提出日時 2021-11-25 00:22:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 215 ms / 3,000 ms
コード長 643 bytes
コンパイル時間 317 ms
コンパイル使用メモリ 86,948 KB
実行使用メモリ 120,408 KB
最終ジャッジ日時 2023-09-09 17:22:07
合計ジャッジ時間 9,709 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,132 KB
testcase_01 AC 71 ms
71,280 KB
testcase_02 AC 68 ms
71,276 KB
testcase_03 AC 215 ms
112,976 KB
testcase_04 AC 214 ms
112,772 KB
testcase_05 AC 212 ms
112,856 KB
testcase_06 AC 167 ms
109,812 KB
testcase_07 AC 167 ms
110,348 KB
testcase_08 AC 190 ms
119,720 KB
testcase_09 AC 189 ms
120,408 KB
testcase_10 AC 190 ms
119,836 KB
testcase_11 AC 189 ms
119,748 KB
testcase_12 AC 189 ms
119,696 KB
testcase_13 AC 178 ms
116,740 KB
testcase_14 AC 197 ms
112,608 KB
testcase_15 AC 104 ms
86,020 KB
testcase_16 AC 94 ms
81,600 KB
testcase_17 AC 153 ms
113,480 KB
testcase_18 AC 143 ms
110,800 KB
testcase_19 AC 128 ms
95,264 KB
testcase_20 AC 85 ms
76,660 KB
testcase_21 AC 106 ms
87,576 KB
testcase_22 AC 151 ms
114,388 KB
testcase_23 AC 86 ms
77,060 KB
testcase_24 AC 85 ms
76,624 KB
testcase_25 AC 133 ms
100,696 KB
testcase_26 AC 137 ms
98,268 KB
testcase_27 AC 126 ms
97,892 KB
testcase_28 AC 88 ms
77,588 KB
testcase_29 AC 143 ms
108,904 KB
testcase_30 AC 128 ms
89,284 KB
testcase_31 AC 186 ms
116,084 KB
testcase_32 AC 125 ms
89,228 KB
testcase_33 AC 94 ms
79,480 KB
testcase_34 AC 179 ms
101,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin
n, q, *indata = map(int, stdin.read().split())
offset = 0
for i in range(q):
    s, t = indata[offset + 2*i],indata[offset + 2*i+1]
    ans = 0
    if s == 0:
        check = True
        while t > 0:
            kari = t & (-t)
            t -= kari
            ans += 1
    else:
        check = True
        while check:
            kari = s & (-s)
            if s + kari <= t:
                s += kari
                ans += 1
            else:
                check = False
        check = True
        while t > s:
            kari = t & (-t)
            t -= kari
            ans += 1
    print("{}".format(ans))
0