結果
問題 |
No.1651 Removing Cards
|
ユーザー |
![]() |
提出日時 | 2021-06-20 18:27:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 367 bytes |
コンパイル時間 | 791 ms |
コンパイル使用メモリ | 76,080 KB |
最終ジャッジ日時 | 2025-01-22 10:47:15 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 TLE * 14 |
ソースコード
#include <iostream> #include <map> using namespace std; typedef long long ll; ll k; map<ll, ll> mp; ll solve(ll x){ if(x<=k) return x-1; if(mp.find(x)!=mp.end()) return mp[x]; ll y=solve(x-(x+k-1)/k); return mp[x]=y/(k-1)*k+1+y%(k-1); } int main() { int q; cin>>k>>q; while(q--){ ll n; cin>>n; printf("%lld\n", solve(n)+1); } return 0; }