結果

問題 No.1742 Binary Indexed Train
ユーザー monkukui2monkukui2
提出日時 2021-11-12 22:49:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,280 bytes
コンパイル時間 3,299 ms
コンパイル使用メモリ 159,120 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-05-04 10:23:21
合計ジャッジ時間 12,133 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 TLE -
testcase_04 TLE -
testcase_05 TLE -
testcase_06 AC 31 ms
6,944 KB
testcase_07 AC 30 ms
6,944 KB
testcase_08 AC 2,226 ms
6,944 KB
testcase_09 AC 2,237 ms
6,944 KB
testcase_10 AC 2,233 ms
6,948 KB
testcase_11 AC 2,273 ms
6,940 KB
testcase_12 AC 2,232 ms
6,944 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 "atcoder/all"
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>
#include <cstddef>
#include <type_traits>
#include <vector>

using namespace std;
const long long int INF = numeric_limits<long long int>::max() / 4;
const int inf = numeric_limits<int>::max() / 4;
const long long int MOD1000000007 = 1000000007;
const long long int MOD998244353 = 998244353;
const double MATH_PI = 3.1415926535897932;

template<typename T1, typename T2>
inline void chmin(T1 &a, const T2 &b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, const T2 &b) { if (a < b) a = b; }

#define lint long long int
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define VI vector<int>
#define VLL vector<long long>
#define VC vector<char>
#define VB vector<bool>
#define PI pair<int, int>
#define PLL pair<long long, long long>
#define VPI vector<pair<int, int>>
#define VPLL vector<pair<long long, long long>>
#define VVI vector<vector<int>>
#define VVPI vecor<vector<pair<int, int>>>
#define VVPILL vector<vector<pair<int, long long>>>

#define SUM(v) accumulate(ALL(v), 0LL)
#define MIN(v) *min_element(ALL(v))
#define MAX(v) *max_element(ALL(v))

int main() {
    lint n, q;
    scanf("%lld %lld", &n, &q);
    vector<lint> po2(n + 1, 1);
    for (int i = 1; i <= n; i++) {
        po2[i] *= po2[i - 1] * 2;
    }
    for (int i = 0; i < q; i++) {
        // cerr << "i = " << i << endl;
        lint s, t;
        scanf("%lld %lld", &s, &t);
        lint ans = 0;
        while (true) {
            for (lint j = n; j >= 0; j--) {
                if (s % po2[j] == 0 and s + po2[j] <= t) {
                    ans += 1;
                    s += po2[j];
                    break;
                }
            }
            if (s == t) {
                printf("%lld\n", ans);
                break;
            }
        }
    }
    return 0;
}
0