結果

問題 No.1665 quotient replace
ユーザー shinichishinichi
提出日時 2021-09-03 21:59:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,264 ms / 3,000 ms
コード長 1,615 bytes
コンパイル時間 318 ms
コンパイル使用メモリ 86,852 KB
実行使用メモリ 257,984 KB
最終ジャッジ日時 2023-08-21 21:46:00
合計ジャッジ時間 30,635 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 378 ms
101,048 KB
testcase_01 AC 374 ms
100,488 KB
testcase_02 AC 379 ms
100,932 KB
testcase_03 AC 383 ms
101,112 KB
testcase_04 AC 382 ms
101,260 KB
testcase_05 AC 373 ms
100,852 KB
testcase_06 AC 418 ms
101,924 KB
testcase_07 AC 394 ms
102,084 KB
testcase_08 AC 427 ms
101,812 KB
testcase_09 AC 436 ms
105,772 KB
testcase_10 AC 675 ms
159,848 KB
testcase_11 AC 1,009 ms
233,904 KB
testcase_12 AC 478 ms
113,548 KB
testcase_13 AC 1,189 ms
257,984 KB
testcase_14 AC 1,194 ms
257,984 KB
testcase_15 AC 1,264 ms
257,980 KB
testcase_16 AC 1,181 ms
257,956 KB
testcase_17 AC 1,176 ms
257,832 KB
testcase_18 AC 380 ms
101,044 KB
testcase_19 AC 384 ms
100,756 KB
testcase_20 AC 383 ms
100,824 KB
testcase_21 AC 382 ms
100,972 KB
testcase_22 AC 403 ms
100,408 KB
testcase_23 AC 387 ms
100,852 KB
testcase_24 AC 378 ms
100,800 KB
testcase_25 AC 379 ms
100,908 KB
testcase_26 AC 398 ms
101,480 KB
testcase_27 AC 421 ms
101,920 KB
testcase_28 AC 428 ms
105,720 KB
testcase_29 AC 436 ms
110,744 KB
testcase_30 AC 655 ms
178,532 KB
testcase_31 AC 796 ms
248,780 KB
testcase_32 AC 984 ms
230,208 KB
testcase_33 AC 614 ms
147,224 KB
testcase_34 AC 849 ms
194,532 KB
testcase_35 AC 828 ms
179,984 KB
testcase_36 AC 856 ms
190,244 KB
testcase_37 AC 811 ms
178,740 KB
testcase_38 AC 904 ms
206,420 KB
testcase_39 AC 750 ms
160,024 KB
testcase_40 AC 759 ms
159,996 KB
testcase_41 AC 747 ms
159,804 KB
testcase_42 AC 373 ms
100,956 KB
testcase_43 AC 380 ms
100,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict


class Eratosthenes():
    def __init__(self, size):
        self.size = size
        self.isprime = [True] * size
        self.minfactor = [-1] * size
        self.mobius = [1] * size
        self.isprime[1] = False
        self.minfactor[1] = 1
        self.eratosthenes()

    # 初めに篩にかけて,minfactorとisprimeを生成
    def eratosthenes(self):
        for p in range(2, self.size):
            if not self.isprime[p]:
                continue
            self.minfactor[p] = p
            self.mobius[p] = -1
            for q in range(p+p, self.size, p):
                self.isprime[q] = False
                if self.minfactor[q] == -1:
                    self.minfactor[q] = p
                if (q//p) % p == 0:
                    self.mobius[q] = 0
                else:
                    self.mobius[q] = -self.mobius[q]

    # 高速素因数分解
    def prime_factorize(self, number):
        assert 1 <= number <= self.size
        factors = defaultdict(int)
        cnt = 0
        while number != 1:
            factors[self.minfactor[number]] += 1
            cnt += 1
            number //= self.minfactor[number]
        return factors, cnt

    # 高速約数列挙
    def divisors(self, number):
        res = [1]
        factors, cnt = self.prime_factorize(number)
        return cnt

N = int(input())
A = list(map(int, input().split()))
Nim = [0] * N
era = Eratosthenes(10**6+1000)
for i in range(N):
    a = A[i]
    Nim[i] = era.divisors(a)

mex = 0
for n in Nim:
    mex ^= n
if mex:
    print("white")
else:
    print("black")

0