結果

問題 No.2725 Coprime Game 2
ユーザー rlangevinrlangevin
提出日時 2024-04-12 22:13:15
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 570 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 82,540 KB
実行使用メモリ 76,676 KB
最終ジャッジ日時 2024-04-12 22:13:36
合計ジャッジ時間 19,344 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,787 ms
74,076 KB
testcase_01 AC 1,787 ms
73,760 KB
testcase_02 WA -
testcase_03 AC 1,845 ms
76,304 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def solve(n):
    if n >= 500:
        return 1
    dp = [0] * (n + 1)
    for i in range(3, n + 1):
        for j in range(2, i):
            if n % j == 0:
                continue
            if gcd(i, j) != 1:
                continue
            dp[i] |= 1 - dp[j]
    return dp[n]
        
M = 500
ans = [0] * M
for i in range(2, M):
    ans[i] = solve(i)

T = int(input())
for _ in range(T):
    N = int(input())
    if N >= 500:
        print("K")
    else:
        print("K") if ans[N] else print("P")
0