結果
| 問題 |
No.1651 Removing Cards
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-08-20 22:55:49 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 826 bytes |
| コンパイル時間 | 2,759 ms |
| コンパイル使用メモリ | 195,052 KB |
| 最終ジャッジ日時 | 2025-01-24 00:13:40 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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 = 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();
cout << ans[ind - 1] << endl;
}
}
}