結果

問題 No.2724 Coprime Game 1
ユーザー PNJPNJ
提出日時 2024-04-12 21:58:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 465 ms / 2,000 ms
コード長 483 bytes
コンパイル時間 327 ms
コンパイル使用メモリ 82,312 KB
実行使用メモリ 100,608 KB
最終ジャッジ日時 2024-04-12 21:58:23
合計ジャッジ時間 4,035 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 172 ms
99,296 KB
testcase_01 AC 180 ms
99,100 KB
testcase_02 AC 176 ms
98,864 KB
testcase_03 AC 402 ms
99,860 KB
testcase_04 AC 465 ms
100,120 KB
testcase_05 AC 431 ms
100,424 KB
testcase_06 AC 342 ms
100,384 KB
testcase_07 AC 402 ms
100,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Prime(N):
  Is_prime = [1 for i in range(N+1)]
  Is_prime[0] = Is_prime[1] = 0
  for p in range(2,N):
    if Is_prime[p] == 0:
      continue
    for d in range(2,N//p + 1):
      Is_prime[p*d] = 0
  return Is_prime

P = Prime(3*10**6)
for i in range(3*10**6):
  P[i+1] += P[i]

T = int(input())
for _ in range(T):
  ans = 'P'
  N = int(input())
  if P[N] - P[N-1]:
    print(ans)
    continue
  else:
    res = N - (P[N] - P[N//2])
    if res % 2:
      ans = 'K'
    print(ans)
0