結果

問題 No.2725 Coprime Game 2
ユーザー PNJPNJ
提出日時 2024-04-12 22:53:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 357 ms / 2,000 ms
コード長 350 bytes
コンパイル時間 234 ms
コンパイル使用メモリ 82,084 KB
実行使用メモリ 77,012 KB
最終ジャッジ日時 2024-04-12 22:53:36
合計ジャッジ時間 3,134 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,828 KB
testcase_01 AC 41 ms
53,352 KB
testcase_02 AC 41 ms
53,636 KB
testcase_03 AC 300 ms
76,544 KB
testcase_04 AC 357 ms
76,928 KB
testcase_05 AC 327 ms
77,012 KB
testcase_06 AC 296 ms
76,788 KB
testcase_07 AC 226 ms
76,848 KB
testcase_08 AC 296 ms
76,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def gcd(a, b):
  while a != 0:
    b %= a
    if b == 0: return a
    a %= b
  return b

T = int(input())
for _ in range(T):
  N = int(input())
  if N == 2:
    print('P')
    continue
  if N % 2:
    print('K')
    continue
  for p in range(2,N+1):
    if N % p == 0:
      continue
    break
  if gcd(N,p) > 1:
    print('P')
  else:
    print('K')
0