結果
問題 | No.1651 Removing Cards |
ユーザー |
|
提出日時 | 2021-08-20 22:55:02 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 844 bytes |
コンパイル時間 | 2,258 ms |
コンパイル使用メモリ | 196,056 KB |
最終ジャッジ日時 | 2025-01-24 00:13:11 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 WA * 16 |
ソースコード
#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 = 8000000000000000000ULL / (K - 1);ull lb = 0;while(ub - lb > 1){long long mid = (ub + lb) / 2;long long t = mid * (K - 1);if(t < temp) lb = mid;else ub = mid;}ans.push_back(ub + temp);}while(Q--){long long N;cin >> N;if(N <= K) cout << N << endl;else{int ind = lower_bound(ans.begin(), ans.end(), N) - ans.begin();cout << ans[ind - 1] << endl;}}}