結果

問題 No.2724 Coprime Game 1
ユーザー 👑 rin204rin204
提出日時 2024-04-12 22:52:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 612 ms / 2,000 ms
コード長 468 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 82,384 KB
実行使用メモリ 253,452 KB
最終ジャッジ日時 2024-04-12 22:52:36
合計ジャッジ時間 5,144 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 294 ms
252,436 KB
testcase_01 AC 316 ms
253,092 KB
testcase_02 AC 335 ms
251,992 KB
testcase_03 AC 516 ms
253,372 KB
testcase_04 AC 612 ms
252,744 KB
testcase_05 AC 543 ms
253,268 KB
testcase_06 AC 427 ms
253,452 KB
testcase_07 AC 596 ms
252,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = 3000300
isprime = [True] * N
isprime[0] = isprime[1] = False
for i in range(2, N):
    if isprime[i]:
        for j in range(i * i, N, i):
            isprime[j] = False

pc = [0]
for i in range(1, N):
    pc.append(pc[-1] + isprime[i])


def solve():
    n = int(input())
    if isprime[n]:
        return True

    c = pc[n] - pc[n // 2]
    return (n - c) % 2 == 0


for _ in range(int(input())):
    if solve():
        print("P")
    else:
        print("K")
0