結果
問題 |
No.1742 Binary Indexed Train
|
ユーザー |
![]() |
提出日時 | 2022-01-19 12:09:00 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 390 ms / 3,000 ms |
コード長 | 601 bytes |
コンパイル時間 | 277 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 83,712 KB |
最終ジャッジ日時 | 2024-11-23 13:47:45 |
合計ジャッジ時間 | 10,256 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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)