結果

問題 No.2725 Coprime Game 2
ユーザー MasKoaTSMasKoaTS
提出日時 2023-01-22 15:54:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 218 ms / 2,000 ms
コード長 321 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 87,248 KB
実行使用メモリ 79,444 KB
最終ジャッジ日時 2023-10-06 00:10:14
合計ジャッジ時間 2,679 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,428 KB
testcase_01 AC 71 ms
71,424 KB
testcase_02 AC 72 ms
71,384 KB
testcase_03 AC 152 ms
79,032 KB
testcase_04 AC 218 ms
79,208 KB
testcase_05 AC 184 ms
79,444 KB
testcase_06 AC 169 ms
79,420 KB
testcase_07 AC 148 ms
78,432 KB
testcase_08 AC 174 ms
79,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from math import gcd
input = sys.stdin.readline

def lcm(x, y):
	return x // gcd(x, y) * y

query = [int(input()) for _ in [0] * int(input())]

def solve(n):
	l = 1
	for i in range(1, n):
		l = lcm(l, i)
		if(n % l != 0):
			return 'K' if(gcd(n, i) == 1) else 'P'
	return 'P'

for n in query:
	print(solve(n))
0