結果

問題 No.1742 Binary Indexed Train
ユーザー monnumonnu
提出日時 2021-11-13 10:57:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 476 ms / 3,000 ms
コード長 584 bytes
コンパイル時間 3,825 ms
コンパイル使用メモリ 226,660 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-18 01:47:36
合計ジャッジ時間 15,672 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 367 ms
4,376 KB
testcase_04 AC 366 ms
4,376 KB
testcase_05 AC 372 ms
4,380 KB
testcase_06 AC 167 ms
4,380 KB
testcase_07 AC 168 ms
4,376 KB
testcase_08 AC 466 ms
4,380 KB
testcase_09 AC 473 ms
4,380 KB
testcase_10 AC 471 ms
4,380 KB
testcase_11 AC 476 ms
4,376 KB
testcase_12 AC 474 ms
4,376 KB
testcase_13 AC 347 ms
4,376 KB
testcase_14 AC 351 ms
4,376 KB
testcase_15 AC 83 ms
4,376 KB
testcase_16 AC 70 ms
4,380 KB
testcase_17 AC 241 ms
4,376 KB
testcase_18 AC 242 ms
4,380 KB
testcase_19 AC 118 ms
4,376 KB
testcase_20 AC 11 ms
4,380 KB
testcase_21 AC 94 ms
4,380 KB
testcase_22 AC 275 ms
4,376 KB
testcase_23 AC 21 ms
4,380 KB
testcase_24 AC 9 ms
4,376 KB
testcase_25 AC 236 ms
4,380 KB
testcase_26 AC 138 ms
4,376 KB
testcase_27 AC 207 ms
4,380 KB
testcase_28 AC 23 ms
4,376 KB
testcase_29 AC 270 ms
4,376 KB
testcase_30 AC 125 ms
4,380 KB
testcase_31 AC 343 ms
4,380 KB
testcase_32 AC 118 ms
4,376 KB
testcase_33 AC 42 ms
4,376 KB
testcase_34 AC 222 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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';
  }
}
0