結果
問題 | No.1665 quotient replace |
ユーザー |
![]() |
提出日時 | 2022-10-19 00:09:39 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,438 bytes |
コンパイル時間 | 286 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 252,672 KB |
最終ジャッジ日時 | 2024-06-29 06:00:24 |
合計ジャッジ時間 | 14,257 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 WA * 10 |
ソースコード
class FastFactorization:"""1 ~ Nの整数を全て素因数分解する O(N√N) -> O(NlogN)Parameters-----------N : int操作対象の上限値Notes-----------前処理にO(NloglogN), クエリでO(logN)"""def __init__(self, N):self.N = Nself.min_factor = [0] * (N+1)self.__Eratosthenes()def __Eratosthenes(self):"""前処理, O(NloglogN)"""self.min_factor[1] = 1for p in range(2, self.N+1):if self.min_factor[p] : continuefor q in range(p, self.N+1, p):self.min_factor[q] = p# 高速素因数分解def factorize(self, n):"""素因数分解を行う,O(logN)Parameters-----------n : int操作対象Returns-----------res : list(tuple[int, int])素因数,冪数を返す。"""res = 1while n > 1:p = self.min_factor[n]power = 1while n % p == 0:n //= ppower += 1res *= powerreturn res-1N = int(input())A = list(map(int, input().split()))ff = FastFactorization(1000000)grundy = 0for a in A:grundy ^= ff.factorize(a)if grundy == 0:print('black')else:print('white')