結果

問題 No.2724 Coprime Game 1
ユーザー 沙耶花沙耶花
提出日時 2024-04-12 21:43:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 508 ms / 2,000 ms
コード長 717 bytes
コンパイル時間 4,746 ms
コンパイル使用メモリ 256,348 KB
実行使用メモリ 38,580 KB
最終ジャッジ日時 2024-04-12 21:43:20
合計ジャッジ時間 8,818 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 266 ms
38,580 KB
testcase_01 AC 267 ms
38,576 KB
testcase_02 AC 266 ms
38,528 KB
testcase_03 AC 437 ms
38,444 KB
testcase_04 AC 442 ms
38,344 KB
testcase_05 AC 508 ms
38,432 KB
testcase_06 AC 351 ms
38,408 KB
testcase_07 AC 427 ms
38,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001


int main(){

	int M = 3000000;
	
	vector<int> minp(M+1);
	for(int i=2;i<=M;i++){
		if(minp[i]==0){
			for(int j=i;j<=M;j+=i){
				minp[j] = i;
			}
		}
	}
	vector<int> ans(M+1);
	dsu D(M+1);
	for(int i=2;i<=M;i++){
		int cv = i;
		while(cv!=1){
			D.merge(i,minp[cv]);
			cv /= minp[cv];
		}
		ans[i] = D.size(i);
	}
	
	int _t;
	cin>>_t;
	rep(_,_t){
		int n;
		cin>>n;
		int a = ans[n];
		a --;
		if(a%2==0)cout<<"P"<<endl;
		else cout<<"K"<<endl;
	}
	
	return 0;
}
0