結果
問題 | No.1742 Binary Indexed Train |
ユーザー |
![]() |
提出日時 | 2021-11-12 21:37:26 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 344 ms / 3,000 ms |
コード長 | 456 bytes |
コンパイル時間 | 1,539 ms |
コンパイル使用メモリ | 167,644 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-25 17:27:06 |
合計ジャッジ時間 | 9,903 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h>using namespace std;int dfs(long long L, long long R, long long l, long long r){if (r <= L || R <= l){return 0;} else if (L <= l && r <= R){return 1;} else {long long m = (l + r) / 2;return dfs(L, R, l, m) + dfs(L, R, m, r);}}int main(){int N, Q;cin >> N >> Q;for (int i = 0; i < Q; i++){long long S, T;cin >> S >> T;cout << dfs(S, T, 0, (long long) 1 << N) << endl;}}