結果

問題 No.2724 Coprime Game 1
コンテスト
ユーザー detteiuu
提出日時 2026-07-16 23:47:50
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 302 ms / 2,000 ms
+ 416µs
コード長 590 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 750 ms
コンパイル使用メモリ 95,860 KB
実行使用メモリ 284,160 KB
最終ジャッジ日時 2026-07-16 23:47:56
合計ジャッジ時間 4,926 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from sys import stdin
input = stdin.readline

def eratosthenes(n):
    sieve = [True] * (n + 1)
    for i in range(int(n**0.5) + 1):
        if i < 2:
            sieve[i] = False
        elif sieve[i]:
            for j in range(i, n//i + 1):
                sieve[i * j] = False
    return sieve

E = eratosthenes(10**6*3)
cum = [0]
for i in range(1, 10**6*3+1):
    cum.append(cum[-1])
    if E[i]: cum[-1] += 1

for _ in range(int(input())):
    N = int(input())

    if E[N]:
        print("P")
    else:
        cnt = N-2-(cum[N-1]-cum[N//2])
        print("K" if cnt%2 == 1 else "P")
0