結果

問題 No.2724 Coprime Game 1
ユーザー ゼットゼット
提出日時 2024-04-12 22:35:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 640 ms / 2,000 ms
コード長 886 bytes
コンパイル時間 211 ms
コンパイル使用メモリ 82,260 KB
実行使用メモリ 265,188 KB
最終ジャッジ日時 2024-04-12 22:35:26
合計ジャッジ時間 5,469 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 342 ms
255,720 KB
testcase_01 AC 350 ms
256,168 KB
testcase_02 AC 419 ms
257,476 KB
testcase_03 AC 581 ms
264,580 KB
testcase_04 AC 564 ms
264,536 KB
testcase_05 AC 628 ms
265,148 KB
testcase_06 AC 481 ms
265,188 KB
testcase_07 AC 640 ms
264,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

pare=[-1]*(6*10**6+1)
size=[1]*(6*10**6+1)
count=[0]*(6*10**6+1)
def root(x):
  while pare[x]!=-1:
    x=pare[x]
  return x
def unite(u,v):
  rootu=root(u)
  rootv=root(v)
  if rootu!=rootv:
    if size[rootu]>=size[rootv]:
      pare[rootv]=rootu
      size[rootu]+=size[rootv]
      count[rootu]+=count[rootv]
    else:
      pare[rootu]=rootv
      size[rootv]+=size[rootu]
      count[rootv]+=count[rootu]
def same(s,t):
  return root(s)==root(t)
result=[0]*(3*10**6+1)
used=[0]*(3*10**6+1)
for x in range(2,3*10**6):
  if used[x]==1:
    continue
  for y in range(2,3*10**6):
    if x*y>3*10**6:
      break
    used[x*y]=1
z=0
for x in range(2,3*10**6+1):
  if used[x]==0:
    result[x]=1
    z+=1
    continue
  if used[x//2]==0 and x%2==0:
    z-=1
  result[x]=(x-1)-z
Q=int(input())
for _ in range(Q):
  N=int(input())
  if result[N]%2==1:
    print('P')
  else:
    print('K')
0