結果
| 問題 |
No.1742 Binary Indexed Train
|
| コンテスト | |
| ユーザー |
momoyuu
|
| 提出日時 | 2023-03-16 13:42:07 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 694 bytes |
| コンパイル時間 | 2,862 ms |
| コンパイル使用メモリ | 242,692 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2024-09-18 09:20:08 |
| 合計ジャッジ時間 | 9,184 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 TLE * 1 -- * 1 |
| other | -- * 32 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ll n,q;
cin>>n>>q;
while(q--){
ll s,t;
cin>>s>>t;
ll ans = 0;
//cout<<(ll)(s&-s)<<endl;
while(true){
//cout<<(s+s&-s)<<endl;
if(s+(s&-s)<=t){
ans++;
s += s&-s;
}else{
break;
}
}
ll now = s & (-s);
while(s<t){
//cout<<s<<endl;
if(now+s<=t){
ans++;
s += now;
}else{
now >>= 1;
}
}
cout<<ans<<endl;
}
//cout<<ans<<endl;
}
momoyuu