結果

問題 No.1651 Removing Cards
ユーザー nawawannawawan
提出日時 2021-08-20 22:56:56
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 229 ms / 2,000 ms
コード長 887 bytes
コンパイル時間 2,314 ms
コンパイル使用メモリ 201,632 KB
実行使用メモリ 9,196 KB
最終ジャッジ日時 2023-08-04 08:49:13
合計ジャッジ時間 10,886 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 20 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 151 ms
4,380 KB
testcase_10 AC 152 ms
4,380 KB
testcase_11 AC 154 ms
4,380 KB
testcase_12 AC 153 ms
4,384 KB
testcase_13 AC 155 ms
4,380 KB
testcase_14 AC 154 ms
4,376 KB
testcase_15 AC 219 ms
7,568 KB
testcase_16 AC 217 ms
7,756 KB
testcase_17 AC 224 ms
7,840 KB
testcase_18 AC 219 ms
8,488 KB
testcase_19 AC 218 ms
9,196 KB
testcase_20 AC 217 ms
8,292 KB
testcase_21 AC 219 ms
8,076 KB
testcase_22 AC 206 ms
7,548 KB
testcase_23 AC 151 ms
4,380 KB
testcase_24 AC 142 ms
4,376 KB
testcase_25 AC 210 ms
8,436 KB
testcase_26 AC 201 ms
7,660 KB
testcase_27 AC 221 ms
8,228 KB
testcase_28 AC 225 ms
7,352 KB
testcase_29 AC 229 ms
7,492 KB
testcase_30 AC 225 ms
8,292 KB
testcase_31 AC 226 ms
7,500 KB
testcase_32 AC 148 ms
4,376 KB
testcase_33 AC 152 ms
4,376 KB
testcase_34 AC 149 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long long K, Q;
    cin >> K >> Q;
    vector<ull> ans;
    ans.push_back(K);
    while(ans.back() <= 1000000000000000000ULL){
        ull temp = ans.back();
        ull ub = 9000000000000000000ULL / (K - 1);
        ull lb = 0;
        while(ub - lb > 1){
            ull mid = (ub + lb) / 2;
            ull t = mid * (K - 1);
            if(t < temp) lb = mid;
            else ub = mid;
        }
        ans.push_back(ub + temp);
    }
    while(Q--){
        ull N;
        cin >> N;
        if(N <= K) cout << N << endl;
        else{
            int ind = lower_bound(ans.begin(), ans.end(), N) - ans.begin();
            if(ans[ind] <= N) cout << ans[ind] << endl;
            else cout << ans[ind - 1] << endl;
        }
    }
}
0