結果

問題 No.1651 Removing Cards
ユーザー chocoruskchocorusk
提出日時 2021-06-20 18:17:11
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 290 bytes
コンパイル時間 597 ms
コンパイル使用メモリ 64,948 KB
最終ジャッジ日時 2025-01-22 10:46:07
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17 TLE * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
typedef long long ll;
ll k;
ll solve(ll x){
	if(x<=k) return x-1;
	ll y=solve(x-(x+k-1)/k);
	return 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;
}
0