結果

問題 No.2724 Coprime Game 1
ユーザー Carpenters-Cat
提出日時 2024-04-12 22:02:15
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 546 bytes
コンパイル時間 2,014 ms
コンパイル使用メモリ 192,776 KB
最終ジャッジ日時 2025-02-21 00:22:18
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 1 WA * 6
権限があれば一括ダウンロードができます

ソースコード

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