結果

問題 No.1665 quotient replace
ユーザー kept1994kept1994
提出日時 2021-09-04 02:35:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 856 ms / 3,000 ms
コード長 1,734 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 86,952 KB
実行使用メモリ 266,104 KB
最終ジャッジ日時 2023-08-22 06:00:35
合計ジャッジ時間 19,014 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
96,348 KB
testcase_01 AC 142 ms
96,648 KB
testcase_02 AC 137 ms
96,396 KB
testcase_03 AC 150 ms
96,352 KB
testcase_04 AC 146 ms
96,652 KB
testcase_05 AC 140 ms
96,516 KB
testcase_06 AC 168 ms
97,212 KB
testcase_07 AC 168 ms
97,332 KB
testcase_08 AC 168 ms
97,168 KB
testcase_09 AC 185 ms
99,880 KB
testcase_10 AC 388 ms
147,084 KB
testcase_11 AC 646 ms
206,952 KB
testcase_12 AC 224 ms
107,596 KB
testcase_13 AC 818 ms
265,828 KB
testcase_14 AC 856 ms
265,508 KB
testcase_15 AC 808 ms
266,056 KB
testcase_16 AC 797 ms
266,104 KB
testcase_17 AC 820 ms
265,912 KB
testcase_18 AC 136 ms
96,460 KB
testcase_19 AC 138 ms
96,452 KB
testcase_20 AC 136 ms
96,472 KB
testcase_21 AC 137 ms
96,324 KB
testcase_22 AC 142 ms
96,448 KB
testcase_23 AC 138 ms
96,520 KB
testcase_24 AC 139 ms
96,516 KB
testcase_25 AC 141 ms
96,520 KB
testcase_26 AC 148 ms
96,876 KB
testcase_27 AC 162 ms
96,704 KB
testcase_28 AC 167 ms
100,104 KB
testcase_29 AC 195 ms
105,880 KB
testcase_30 AC 383 ms
182,436 KB
testcase_31 AC 488 ms
215,572 KB
testcase_32 AC 616 ms
193,340 KB
testcase_33 AC 350 ms
128,420 KB
testcase_34 AC 543 ms
194,120 KB
testcase_35 AC 504 ms
182,892 KB
testcase_36 AC 520 ms
192,464 KB
testcase_37 AC 498 ms
182,356 KB
testcase_38 AC 576 ms
206,184 KB
testcase_39 AC 457 ms
167,688 KB
testcase_40 AC 454 ms
167,932 KB
testcase_41 AC 458 ms
167,520 KB
testcase_42 AC 138 ms
96,352 KB
testcase_43 AC 145 ms
96,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
import sys

class Eratosthenes():
    def __init__(self, N: int) -> None:
        self.isPrime = [True] * (N + 1) # 数iが素数かどうかのフラグ
        self.isPrime[0] = False
        self.isPrime[1] = False
        self.minfactor = [0] * (N + 1) # 数iの最小の素因数
        self.minfactor[1] = 1
        self.primes = []    # 数Nまでの素数のリスト
        for p in range(2, N + 1):  # p : 判定対象の数
            if not self.isPrime[p]:
                continue
            self.minfactor[p] = p
            self.primes.append(p)
            # pが素数のためそれ以降に出現するpの倍数を除外する。
            # なお、ループはp始まりでも良いが、p * _ のかける側はすでに同じ処理で弾かれているはずのため無駄。
            for i in range(p * p, N + 1, p):
                if self.minfactor[i] == 0:
                    self.minfactor[i] = p
                self.isPrime[i] = False
        return
    
    def getPrimes(self):
        return self.primes
    
    def factorize(self, n: int) -> list:
        res = [] # (p, exp)
        while n > 1:
            p = self.minfactor[n]
            exp = 0
            while self.minfactor[n] == p:
                n //= p
                exp += 1
            res.append((p, exp))
        return res

def main():
    N = int(input())
    A = list(map(int, input().split()))
    er = Eratosthenes(10 ** 6 + 1)
    pf = []
    for aa in A:
        s = 0
        for _, exp in er.factorize(aa):
            s += exp
        pf.append(s)
    ans = 0
    for i in pf:
        ans ^= i
    print("white" if ans else "black")
    return

if __name__ == '__main__':
    main()
0