結果

問題 No.2724 Coprime Game 1
ユーザー ニックネームニックネーム
提出日時 2024-04-12 23:09:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 780 ms / 2,000 ms
コード長 787 bytes
コンパイル時間 378 ms
コンパイル使用メモリ 82,852 KB
実行使用メモリ 150,848 KB
最終ジャッジ日時 2024-04-12 23:09:43
合計ジャッジ時間 5,844 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 294 ms
148,836 KB
testcase_01 AC 310 ms
149,020 KB
testcase_02 AC 357 ms
149,100 KB
testcase_03 AC 570 ms
150,412 KB
testcase_04 AC 780 ms
150,460 KB
testcase_05 AC 685 ms
150,848 KB
testcase_06 AC 599 ms
150,460 KB
testcase_07 AC 659 ms
150,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class PrimeNumbers:
    def __init__(self,nmax):
        from math import isqrt
        rootnmax = isqrt(nmax)
        self.prime_judgement = [True]*(rootnmax+1)
        self.prime_judgement[0] = self.prime_judgement[1] = False
        for i in range(2,rootnmax+1):
            if self.prime_judgement[i]:
                for j in range(2,rootnmax//i+1):
                    self.prime_judgement[i*j] = False
        self.prime_list = []
        for i,flag in enumerate(self.prime_judgement):
            if flag: self.prime_list.append(i)
from bisect import bisect_right
pn = PrimeNumbers(9*10**12); a = pn.prime_list; b = set(a)
for _ in range(int(input())):
    n = int(input())
    if n in b: print("P")
    else: print("K" if (n-2-bisect_right(a,n)+bisect_right(a,n//2))%2 else "P")
0