結果

問題 No.1742 Binary Indexed Train
ユーザー gr1msl3ygr1msl3y
提出日時 2021-11-13 01:56:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 460 ms / 3,000 ms
コード長 321 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 86,940 KB
実行使用メモリ 95,400 KB
最終ジャッジ日時 2023-08-17 11:39:20
合計ジャッジ時間 12,679 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
70,964 KB
testcase_01 AC 70 ms
70,980 KB
testcase_02 AC 70 ms
71,264 KB
testcase_03 AC 441 ms
94,884 KB
testcase_04 AC 442 ms
94,896 KB
testcase_05 AC 440 ms
94,836 KB
testcase_06 AC 242 ms
93,576 KB
testcase_07 AC 240 ms
93,484 KB
testcase_08 AC 452 ms
95,348 KB
testcase_09 AC 453 ms
95,224 KB
testcase_10 AC 456 ms
95,400 KB
testcase_11 AC 460 ms
95,336 KB
testcase_12 AC 458 ms
95,368 KB
testcase_13 AC 417 ms
93,552 KB
testcase_14 AC 426 ms
93,604 KB
testcase_15 AC 181 ms
81,808 KB
testcase_16 AC 175 ms
79,576 KB
testcase_17 AC 304 ms
93,732 KB
testcase_18 AC 302 ms
92,708 KB
testcase_19 AC 219 ms
87,424 KB
testcase_20 AC 130 ms
78,312 KB
testcase_21 AC 189 ms
84,048 KB
testcase_22 AC 318 ms
94,880 KB
testcase_23 AC 140 ms
78,872 KB
testcase_24 AC 128 ms
78,028 KB
testcase_25 AC 295 ms
87,144 KB
testcase_26 AC 242 ms
87,908 KB
testcase_27 AC 271 ms
85,680 KB
testcase_28 AC 138 ms
78,696 KB
testcase_29 AC 316 ms
91,604 KB
testcase_30 AC 225 ms
83,340 KB
testcase_31 AC 414 ms
94,992 KB
testcase_32 AC 219 ms
82,652 KB
testcase_33 AC 151 ms
79,028 KB
testcase_34 AC 308 ms
88,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, Q = map(int, input().split())
query = [list(map(int, input().split())) for _ in range(Q)]
ans = []
for s, t in query:
    for i in range(N-1, -1, -1):
        m = ((s-1)//(1 << i)+1)*(1 << i)
        if t >= m:
            break
    ans.append(str(bin(s-m)).count('1')+str(bin(t-m)).count('1'))

print(*ans, sep='\n')
0