結果

問題 No.1665 quotient replace
ユーザー satama6satama6
提出日時 2022-10-18 23:33:13
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,431 bytes
コンパイル時間 335 ms
コンパイル使用メモリ 87,108 KB
実行使用メモリ 266,300 KB
最終ジャッジ日時 2023-09-11 15:22:13
合計ジャッジ時間 16,216 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 66 ms
71,384 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 111 ms
92,092 KB
testcase_05 WA -
testcase_06 AC 137 ms
93,132 KB
testcase_07 AC 125 ms
92,832 KB
testcase_08 AC 129 ms
93,208 KB
testcase_09 AC 143 ms
95,580 KB
testcase_10 AC 306 ms
142,008 KB
testcase_11 AC 565 ms
196,088 KB
testcase_12 AC 169 ms
104,064 KB
testcase_13 AC 824 ms
265,048 KB
testcase_14 AC 964 ms
264,976 KB
testcase_15 AC 766 ms
266,244 KB
testcase_16 AC 771 ms
266,300 KB
testcase_17 AC 810 ms
265,668 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 152 ms
96,232 KB
testcase_29 WA -
testcase_30 AC 359 ms
178,572 KB
testcase_31 AC 459 ms
209,704 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 WA -
testcase_43 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

# 1 ~ Nの整数を全て素因数分解する O(N√N) -> O(NlogN)

class FastFactorization:
    def __init__(self, N):
        self.N = N
        self.is_prime = [True] * (N+1)
        self.min_factor = [-1] * (N+1) # min_factor[i]:整数iを割り切る最小の素数

        self.Eratosthenes()

    # 前処理 O(N loglogN)
    def Eratosthenes(self):
        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 <= N:
                self.is_prime[q] = False
                if self.min_factor[q] == -1:
                    self.min_factor[q] = p
                q += p
            
    # 高速素因数分解
    def factorize(self, n):
        res = []
        while n > 1:
            p = self.min_factor[n]
            power = 0
            while n % p == 0:
                n //= p
                power += 1
            res.append((p, power))
        return len(res) - 1

    def main(self):
        self.Eratosthenes()
        for i in range(2, self.N+1):
            print(len(self.factorize(i)))


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

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

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