結果

問題 No.1651 Removing Cards
ユーザー kotatsugame
提出日時 2021-08-24 20:02:11
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 359 ms / 2,000 ms
コード長 387 bytes
コンパイル時間 681 ms
コンパイル使用メモリ 72,808 KB
実行使用メモリ 9,424 KB
最終ジャッジ日時 2024-11-15 08:40:55
合計ジャッジ時間 10,517 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int K,T;
long N;
vector<long>A;
main()
{
	cin>>K>>T;
	A.push_back(0);
	while(true)
	{
		long pre=A.back()+1;
		long now=pre;
		while(now-now/K<pre)now=pre+now/K;
		A.push_back(now);
		if(now>=(long)1e18)break;
	}
	for(;T--;)
	{
		cin>>N;
		auto it=lower_bound(A.begin(),A.end(),N);
		cout<<*--it+1<<endl;
	}
}
0