結果

問題 No.2725 Coprime Game 2
ユーザー MasKoaTSMasKoaTS
提出日時 2023-03-03 13:29:41
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 181 ms / 2,000 ms
コード長 508 bytes
コンパイル時間 1,768 ms
コンパイル使用メモリ 193,788 KB
最終ジャッジ日時 2025-02-11 01:25:39
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll gcd(ll a, ll b) {
	while (b != 0) {
		ll r = a % b;
		a = b;
		b = r;
	}
	return a;
}

void solve(ll n) {
	for (ll i = 2; i < n; i++) {
		if (n % i == 0) {
			continue;
		}
		if (gcd(n, i) == 1) {
			cout << 'K' << endl;
			return;
		}
		break;
	}
	cout << 'P' << endl;
}


int main(void) {
	int t;	cin >> t;
	vector<ll> query(t);
	for (int i = 0; i < t; i++) {
		cin >> query[i];
	}

	for (ll n : query) {
		solve(n);
	}

	return 0;
}
0