結果
| 問題 | No.1742 Binary Indexed Train |
| コンテスト | |
| ユーザー |
brthyyjp
|
| 提出日時 | 2022-01-19 12:09:00 |
| 言語 | PyPy3 (8.0.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 125 ms / 3,000 ms |
| + 167µs | |
| コード長 | 601 bytes |
| 記録 | |
| コンパイル時間 | 64 ms |
| コンパイル使用メモリ | 82,296 KB |
| 実行使用メモリ | 91,128 KB |
| 最終ジャッジ日時 | 2026-09-28 15:35:08 |
| 合計ジャッジ時間 | 8,320 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
ソースコード
import sys
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
def popcount(x):
x = x - ((x >> 1) & 0x5555555555555555)
x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
x = x + (x >> 8)
x = x + (x >> 16)
x = x + (x >> 32)
return x & 0x0000007f
n, q = map(int, input().split())
for i in range(q):
s, t = map(int, input().split())
for i in range(n+1):
if (s-1)//(1<<i) != (t-1)//(1<<i):
mid = (1<<i)*(t//(1<<i))
ans = popcount(mid-s)+popcount(t-mid)
print(ans)
brthyyjp