結果
| 問題 |
No.2724 Coprime Game 1
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-12 22:14:30 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 582 bytes |
| コンパイル時間 | 279 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 110,208 KB |
| 最終ジャッジ日時 | 2024-10-02 23:23:33 |
| 合計ジャッジ時間 | 6,579 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | TLE * 1 |
| other | -- * 7 |
ソースコード
from math import gcd
def soln(N):
vis = [False] * (N + 1)
vis[1] = True
def find_coprime(x):
for i in range(2, N + 1):
if vis[i] or gcd(x, i) == 1:
continue
return i
return -1
x = 2
while True:
y = find_coprime(x)
if y == -1:
return "K"
vis[y] = True
x = y
y = find_coprime(x)
if y == -1:
return "P"
vis[y] = True
x = y
T = int(input())
for _ in range(T):
N = int(input())
print(soln(N))