結果
| 問題 |
No.1665 quotient replace
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 20:21:39 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 590 ms / 3,000 ms |
| コード長 | 937 bytes |
| コンパイル時間 | 152 ms |
| コンパイル使用メモリ | 82,344 KB |
| 実行使用メモリ | 247,892 KB |
| 最終ジャッジ日時 | 2025-03-20 20:23:31 |
| 合計ジャッジ時間 | 11,935 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 |
ソースコード
import sys
def main():
input = sys.stdin.read().split()
N = int(input[0])
A = list(map(int, input[1:N+1]))
if N == 0:
print("black")
return
max_a = max(A)
max_spf = 10**6
# Initialize smallest prime factors (spf)
spf = list(range(max_spf + 1))
for i in range(2, int(max_spf**0.5) + 1):
if spf[i] == i:
for j in range(i * i, max_spf + 1, i):
if spf[j] == j:
spf[j] = i
grundy_xor = 0
for a in A:
if a == 1:
grundy_xor ^= 0
continue
x = a
total = 0
while x != 1:
p = spf[x]
count = 0
while x % p == 0:
count += 1
x = x // p
total += count
grundy_xor ^= total
print("white" if grundy_xor != 0 else "black")
if __name__ == "__main__":
main()
lam6er