結果

問題 No.1665 quotient replace
ユーザー satama6satama6
提出日時 2022-10-18 23:49:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,718 bytes
コンパイル時間 481 ms
コンパイル使用メモリ 87,324 KB
実行使用メモリ 265,808 KB
最終ジャッジ日時 2023-09-11 15:37:06
合計ジャッジ時間 17,260 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,472 KB
testcase_01 AC 71 ms
71,500 KB
testcase_02 AC 70 ms
71,256 KB
testcase_03 AC 163 ms
91,700 KB
testcase_04 AC 153 ms
91,848 KB
testcase_05 AC 149 ms
91,520 KB
testcase_06 AC 186 ms
93,168 KB
testcase_07 AC 157 ms
92,356 KB
testcase_08 AC 160 ms
92,424 KB
testcase_09 AC 186 ms
95,632 KB
testcase_10 AC 378 ms
142,540 KB
testcase_11 AC 614 ms
196,788 KB
testcase_12 AC 215 ms
104,716 KB
testcase_13 AC 747 ms
265,808 KB
testcase_14 AC 738 ms
265,540 KB
testcase_15 AC 740 ms
265,696 KB
testcase_16 AC 756 ms
265,796 KB
testcase_17 AC 755 ms
265,484 KB
testcase_18 AC 112 ms
84,496 KB
testcase_19 AC 98 ms
81,032 KB
testcase_20 AC 115 ms
85,324 KB
testcase_21 AC 119 ms
86,088 KB
testcase_22 AC 104 ms
82,340 KB
testcase_23 AC 132 ms
88,356 KB
testcase_24 AC 112 ms
84,380 KB
testcase_25 AC 100 ms
82,092 KB
testcase_26 AC 152 ms
92,696 KB
testcase_27 AC 158 ms
92,540 KB
testcase_28 AC 190 ms
96,108 KB
testcase_29 AC 188 ms
101,752 KB
testcase_30 AC 364 ms
178,540 KB
testcase_31 AC 463 ms
211,468 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 72 ms
71,308 KB
testcase_43 AC 70 ms
71,264 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.is_prime = [True] * (N+1)
        self.min_factor = [-1] * (N+1)
        self.__Eratosthenes()

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

        for p in range(2, self.N+1):
            if not self.is_prime[p]:
                continue
            self.min_factor[p] = p
            q = p + p
            while q <= self.N:
                self.is_prime[q] = False
                if self.min_factor[q] == -1:
                    self.min_factor[q] = p
                q += p
            
    # 高速素因数分解
    def factorize(self, n):
        """
        素因数分解を行う,O(logN)
        
        Parameters
        -----------
        n : int
            操作対象
        
        Returns
        -----------
        res : list(tuple[int, int])
            素因数,冪数を返す。
        """
        res = 1
        while n > 1:
            p = self.min_factor[n]
            power = 0
            while n % p == 0:
                n //= p
                power += 1
            res *= power+1
        return res-1



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

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

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