結果

問題 No.2724 Coprime Game 1
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2024-04-12 22:02:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 546 bytes
コンパイル時間 2,545 ms
コンパイル使用メモリ 195,336 KB
実行使用メモリ 15,312 KB
最終ジャッジ日時 2024-04-12 22:02:20
合計ジャッジ時間 4,447 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 183 ms
15,284 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
constexpr int L = 3000000;
int main () {
	bool is_s[L + 1];
	is_s[0] = is_s[1] = 0;
	for (int i = 2; i <= L; i ++) {
		if (is_s[i]) {
			for (int j = 2; j * i <= L; j ++) {
				is_s[i * j] = false;
			}
		}
	}
	int num[L + 1];
	num[0] = num[1] = 0;
	for (int i = 2; i <= L; i ++) {
		num[i] = num[i - 1] + is_s[i];
	}
	int T;
	cin >> T;
	while(T--) {
		int N;
		cin >> N;
		if (is_s[N]) {
			puts("P");
		} else {
			int n = N - (num[N] - num[N / 2]);
			cout << (n & 1 ? "P" : "K") << endl;
		}
	}
}
0