結果
| 問題 |
No.1742 Binary Indexed Train
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-01 17:49:58 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 98 ms / 3,000 ms |
| コード長 | 418 bytes |
| コンパイル時間 | 3,060 ms |
| コンパイル使用メモリ | 274,348 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-09-01 17:50:06 |
| 合計ジャッジ時間 | 7,649 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int N, Q;
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
cin >> N >> Q;
for (; Q--;) {
long long S, T;
cin >> S >> T;
int ans = 0;
for (int p = 0; S < T; S >>= 1, T >>= 1, p++) {
if (S & 1) ans++, S++;
if (T & 1) ans++, T--;
}
cout << ans << "\n";
}
}