結果

問題 No.1742 Binary Indexed Train
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-05-30 00:46:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 688 bytes
コンパイル時間 906 ms
コンパイル使用メモリ 105,820 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-28 00:15:44
合計ジャッジ時間 12,689 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 TLE -
testcase_04 TLE -
testcase_05 TLE -
testcase_06 AC 165 ms
4,380 KB
testcase_07 AC 165 ms
4,380 KB
testcase_08 AC 2,414 ms
4,376 KB
testcase_09 AC 2,415 ms
4,380 KB
testcase_10 AC 2,407 ms
4,380 KB
testcase_11 AC 2,414 ms
4,376 KB
testcase_12 AC 2,409 ms
4,376 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;
using ll = long long;

int main(){

    ll N, Q, S, T, ans;
    cin >> N >> Q;

    while(Q){
        Q--;
        ans = 0;
        cin >> S >> T;
        while(S != T){
            for (int i=N; i>=0; i--){
                if (S % (1LL<<i) == 0 && S+(1LL<<i) <= T){
                    S += (1LL<<i);
                    ans++;
                    break;
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}
0