結果
問題 | No.1742 Binary Indexed Train |
ユーザー |
![]() |
提出日時 | 2022-03-24 15:43:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 317 ms / 3,000 ms |
コード長 | 467 bytes |
コンパイル時間 | 1,532 ms |
コンパイル使用メモリ | 169,664 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-12 23:59:19 |
合計ジャッジ時間 | 8,576 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define rep(i,n) for(int i = 0;i < (n);i++)using ll = long long;using P =pair<int,int>;ll LEN = 1LL << 60;int main(){int n,q;cin >> n >> q;vector<int> ans;rep(i,q){ll s,t;cin >> s >> t;int res = 0;while(s < t){if(s & 1) res++,s++;if(t & 1) res++,t--;s /= 2;t /= 2;}ans.push_back(res);}rep(i,q){cout << ans[i] << endl;}return 0;}