結果
問題 |
No.1665 quotient replace
|
ユーザー |
![]() |
提出日時 | 2025-03-20 18:42:23 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 714 ms / 3,000 ms |
コード長 | 937 bytes |
コンパイル時間 | 210 ms |
コンパイル使用メモリ | 82,628 KB |
実行使用メモリ | 247,968 KB |
最終ジャッジ日時 | 2025-03-20 18:42:47 |
合計ジャッジ時間 | 11,438 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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()