結果
問題 | No.1742 Binary Indexed Train |
ユーザー |
![]() |
提出日時 | 2021-11-12 21:45:02 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 384 ms / 3,000 ms |
コード長 | 948 bytes |
コンパイル時間 | 3,011 ms |
コンパイル使用メモリ | 180,860 KB |
最終ジャッジ日時 | 2025-01-25 16:16:49 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
#include <cstdio>#include <cstring>#include <iostream>#include <string>#include <cmath>#include <bitset>#include <vector>#include <map>#include <set>#include <queue>#include <deque>#include <algorithm>#include <complex>#include <unordered_map>#include <unordered_set>#include <random>#include <cassert>#include <fstream>#include <utility>#include <functional>#include <time.h>#include <stack>#include <array>#include <list>#include <atcoder/all>#define popcount __builtin_popcountusing namespace std;using namespace atcoder;typedef long long ll;typedef pair<int, int> P;using mint=modint998244353;int n;int solve(ll s, ll t, ll a=0, ll b=(1ll<<n)){if(s<=a && b<=t)return 1;if(s>=b || a>=t)return 0;return solve(s, t, a, (a+b)/2)+solve(s, t, (a+b)/2, b);}int main(){int q;cin>>n>>q;while(q--){ll s, t;cin>>s>>t;cout<<solve(s, t)<<endl;}return 0;}