結果

問題 No.1665 quotient replace
ユーザー satama6satama6
提出日時 2022-10-19 00:11:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 694 ms / 3,000 ms
コード長 1,387 bytes
コンパイル時間 507 ms
コンパイル使用メモリ 86,596 KB
実行使用メモリ 258,168 KB
最終ジャッジ日時 2023-09-11 15:55:44
合計ジャッジ時間 14,469 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
83,412 KB
testcase_01 AC 99 ms
83,288 KB
testcase_02 AC 96 ms
83,564 KB
testcase_03 AC 102 ms
83,756 KB
testcase_04 AC 102 ms
83,476 KB
testcase_05 AC 102 ms
83,416 KB
testcase_06 AC 113 ms
84,568 KB
testcase_07 AC 107 ms
84,200 KB
testcase_08 AC 109 ms
84,340 KB
testcase_09 AC 123 ms
87,664 KB
testcase_10 AC 300 ms
132,692 KB
testcase_11 AC 526 ms
182,516 KB
testcase_12 AC 203 ms
95,944 KB
testcase_13 AC 667 ms
257,160 KB
testcase_14 AC 694 ms
257,108 KB
testcase_15 AC 658 ms
257,300 KB
testcase_16 AC 625 ms
257,324 KB
testcase_17 AC 623 ms
258,168 KB
testcase_18 AC 97 ms
83,532 KB
testcase_19 AC 98 ms
83,404 KB
testcase_20 AC 97 ms
83,916 KB
testcase_21 AC 95 ms
83,872 KB
testcase_22 AC 98 ms
83,424 KB
testcase_23 AC 97 ms
83,508 KB
testcase_24 AC 95 ms
83,968 KB
testcase_25 AC 98 ms
83,604 KB
testcase_26 AC 102 ms
83,960 KB
testcase_27 AC 102 ms
84,160 KB
testcase_28 AC 112 ms
87,792 KB
testcase_29 AC 128 ms
93,428 KB
testcase_30 AC 306 ms
169,228 KB
testcase_31 AC 398 ms
201,556 KB
testcase_32 AC 491 ms
174,896 KB
testcase_33 AC 260 ms
115,328 KB
testcase_34 AC 422 ms
185,368 KB
testcase_35 AC 403 ms
172,156 KB
testcase_36 AC 407 ms
182,804 KB
testcase_37 AC 378 ms
169,256 KB
testcase_38 AC 435 ms
198,420 KB
testcase_39 AC 330 ms
154,760 KB
testcase_40 AC 344 ms
154,636 KB
testcase_41 AC 351 ms
154,680 KB
testcase_42 AC 97 ms
83,612 KB
testcase_43 AC 96 ms
83,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class FastFactorization:
    """
    1 ~ Nの整数を全て素因数分解する O(N√N) -> O(NlogN)
    
    Parameters
    -----------
    N : int
        操作対象の上限値

    Notes
    -----------
    前処理にO(NloglogN), クエリでO(logN)    
    """
    def __init__(self, N):
        self.N = N
        self.min_factor = [0] * (N+1)
        self.__Eratosthenes()

    def __Eratosthenes(self):
        """
        前処理, O(NloglogN)
        """
        self.min_factor[1] = 1

        for p in range(2, self.N+1):
            if self.min_factor[p] : continue

            for 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 = 0
        while n > 1:
            p = self.min_factor[n]
            while n % p == 0:
                n //= p
                res += 1
        return res



N = int(input())
A = list(map(int, input().split()))
ff = FastFactorization(1000000)
grundy = 0

for a in A:
    grundy ^= ff.factorize(a)

if grundy == 0:
    print('black')
else:
    print('white')
0