結果

問題 No.2724 Coprime Game 1
ユーザー kotatsugamekotatsugame
提出日時 2024-04-12 21:43:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 438 bytes
コンパイル時間 472 ms
コンパイル使用メモリ 64,948 KB
実行使用メモリ 28,244 KB
最終ジャッジ日時 2024-04-12 21:43:27
合計ジャッジ時間 1,635 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
28,244 KB
testcase_01 AC 43 ms
28,060 KB
testcase_02 AC 44 ms
28,132 KB
testcase_03 AC 53 ms
28,088 KB
testcase_04 AC 66 ms
28,192 KB
testcase_05 AC 63 ms
28,072 KB
testcase_06 AC 50 ms
28,176 KB
testcase_07 AC 65 ms
28,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cassert>
using namespace std;
int pf[3<<20];
int cnt[3<<20];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	for(int i=2;i<3<<20;i++)if(pf[i]==0)
	{
		for(int j=i+i;j<3<<20;j+=i)pf[j]=i;
	}
	for(int i=2;i<3<<20;i++)cnt[i]=cnt[i-1]+!pf[i];
	int T;cin>>T;
	for(;T--;)
	{
		int N;cin>>N;
		if(pf[N]==0)cout<<"P\n";
		else
		{
			int t=N;
			t-=cnt[N]-cnt[N/2];
			cout<<(t%2?"K\n":"P\n");
		}
	}
}
0