結果
| 問題 |
No.1742 Binary Indexed Train
|
| コンテスト | |
| ユーザー |
monnu
|
| 提出日時 | 2021-11-13 10:57:35 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 510 ms / 3,000 ms |
| コード長 | 584 bytes |
| コンパイル時間 | 3,901 ms |
| コンパイル使用メモリ | 228,556 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-27 03:32:15 |
| 合計ジャッジ時間 | 14,270 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll=long long;
using Graph=vector<vector<pair<int,ll>>>;
#define INF 1000000000
#define MOD 998244353
#define MAX 300000
int main(){
int N,Q;
cin>>N>>Q;
for(int q=0;q<Q;q++){
ll S,T;
cin>>S>>T;
int ans=0;
for(int i=0;i<=N;i++){
if(S%(1LL<<(i+1))!=0&&S+(1LL<<i)<=T){
S+=1LL<<i;
ans++;
}
}
for(int i=N;i>=0;i--){
if(S%(1LL<<i)==0&&S+(1LL<<i)<=T){
S+=1LL<<i;
ans++;
}
}
cout<<ans<<'\n';
}
}
monnu