結果
問題 | No.1651 Removing Cards |
ユーザー |
![]() |
提出日時 | 2021-08-20 22:52:12 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,080 bytes |
コンパイル時間 | 1,103 ms |
コンパイル使用メモリ | 105,684 KB |
最終ジャッジ日時 | 2025-01-24 00:10:39 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 TLE * 15 |
ソースコード
#include <algorithm>#include <cmath>#include <iomanip>#include <iostream>#include <map>#include <queue>#include <set>#include <string>#include <tuple>#include <vector>#define mkp make_pair#define mkt make_tuple#define rep(i, n) for (int i = 0; i < (int)(n); ++i)#define all(v) v.begin(), v.end()using namespace std;typedef long long ll;const ll MOD = 1e9 + 7;// const ll MOD = 998244353;template <class T>void chmin(T &a, const T &b) {if (a > b) a = b;}template <class T>void chmax(T &a, const T &b) {if (a < b) a = b;}void solve() {ll K;int Q;cin >> K >> Q;vector<ll> X(Q);rep(q, Q) cin >> X[q];auto rec = [&](auto &&rec, ll n) -> ll {if (n <= K) return n;ll removed = 1 + (n - 1) / K;ll val = rec(rec, n - removed);ll res = val + 1 + (val - 1) / (K - 1);return res;};for (auto N : X) {ll ans = rec(rec, N);cout << ans << "\n";}}int main() {cin.tie(nullptr);ios::sync_with_stdio(false);solve();return 0;}