結果
| 問題 |
No.1742 Binary Indexed Train
|
| コンテスト | |
| ユーザー |
gr1msl3y
|
| 提出日時 | 2021-11-12 22:33:41 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 468 bytes |
| コンパイル時間 | 353 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 91,648 KB |
| 最終ジャッジ日時 | 2024-11-25 19:54:00 |
| 合計ジャッジ時間 | 8,689 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 12 WA * 20 |
ソースコード
N, Q = map(int, input().split())
query = [list(map(int, input().split())) for _ in range(Q)]
ans = [0]*Q
for i in range(Q):
s, t = query[i]
if s == 0:
ans[i] = str(bin(t)).count('1')
continue
ct = 0
ind = t.bit_length()-1
for j in range(ind):
if (s >> j) & 1:
ct += 1
s += 1 << j
for j in range(ind-1, -1, -1):
if (t >> j) & 1:
ct += 1
ans[i] = ct
print(*ans, sep='\n')
gr1msl3y