結果
| 問題 |
No.1651 Removing Cards
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-09-06 11:53:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 895 bytes |
| コンパイル時間 | 1,415 ms |
| コンパイル使用メモリ | 162,644 KB |
| 実行使用メモリ | 18,080 KB |
| 最終ジャッジ日時 | 2025-09-06 11:54:00 |
| 合計ジャッジ時間 | 10,361 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 TLE * 1 -- * 19 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x){
x=0;
int f=1;
char ch=getchar();
while(!isdigit(ch)){
if(ch=='-') f=-1;
ch=getchar();
}
while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
x*=f;
return ;
}
template <typename T>
inline void write(T x){
if(x<0) putchar('-'),x=-x;
if(x>9) write(x/10);
putchar(x%10+'0');
return ;
}
typedef long long ll;
ll n,k,O;
ll work(ll x){
if(x<k) return x;
if(x<=0) return 0;
ll val=x/k+1,cnt=(x%k)/val;
if(!cnt){
ll pre=work(x-val);
return pre/(k-1)+pre+1;
}
else{
ll pre=work(x-val*cnt);
return pre+cnt*val;
}
}
void solve(){
read(n);
ll ans=work(n-1)+1;
write(ans);
putchar('\n');
}
int main(){
// freopen("coin.in","r",stdin);
// freopen("coin.out","w",stdout);
int T=1;
read(k);read(T);
while(T--) solve();
return 0;
}
vjudge1