結果

問題 No.2724 Coprime Game 1
ユーザー titiatitia
提出日時 2024-04-13 02:09:20
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 630 bytes
コンパイル時間 392 ms
コンパイル使用メモリ 82,556 KB
実行使用メモリ 100,356 KB
最終ジャッジ日時 2024-04-13 02:09:23
合計ジャッジ時間 3,026 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
84,976 KB
testcase_01 AC 157 ms
84,512 KB
testcase_02 WA -
testcase_03 AC 171 ms
99,548 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline


x=3030300

Primelist=[i for i in range(x+1)]
Primelist[1]=0 # 1は素数でないので0にする.
 
for i in Primelist:
    if i*i>x:
        break
    if i==0:
        continue
    for j in range(2*i,x+1,i):
        Primelist[j]=0

for i in range(x+1):
    if Primelist[i]!=0:
        Primelist[i]=1

for i in range(1,x+1):
    Primelist[i]+=Primelist[i-1]

T=int(input())
for tests in range(T):
    N=int(input())

    if Primelist[N]==1:
        print("P")
        continue

    ANS=N-1-(Primelist[N-1]-Primelist[N//2])

    if ANS%2!=0:
        print("P")
    else:
        print("K")
0