結果
| 問題 |
No.1881 Everything is the same...
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 16:12:06 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,232 bytes |
| コンパイル時間 | 177 ms |
| コンパイル使用メモリ | 82,352 KB |
| 実行使用メモリ | 78,384 KB |
| 最終ジャッジ日時 | 2025-06-12 16:12:19 |
| 合計ジャッジ時間 | 4,856 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 WA * 25 |
ソースコード
def compute_spf(max_num):
spf = list(range(max_num + 1))
for i in range(2, int(max_num ** 0.5) + 1):
if spf[i] == i: # i is a prime
for j in range(i * i, max_num + 1, i):
if spf[j] == j:
spf[j] = i
return spf
def compute_phi(a, spf):
if a == 1:
return 1
original = a
res = 1
factors = {}
while a != 1:
p = spf[a]
if p not in factors:
factors[p] = 0
factors[p] += 1
a //= p
for p, cnt in factors.items():
if cnt == 1:
res *= (p - 1)
else:
res *= (p - 1) * (p ** (cnt - 1))
return res
def main():
import sys
input = sys.stdin.read().split()
idx = 0
N = int(input[idx])
idx += 1
A = list(map(int, input[idx:idx + N]))
idx += N
max_a = max(A) if A else 0
max_spf = max(1, max_a)
spf = compute_spf(max_spf)
S = 0
for a in A:
if a == 1:
contrib = 0
else:
phi = compute_phi(a, spf)
contrib = phi - 1
S += contrib
if S == 0:
print("X")
else:
print("X" if S % 2 == 1 else "Y")
if __name__ == "__main__":
main()
gew1fw