結果

問題 No.1665 quotient replace
ユーザー rlangevinrlangevin
提出日時 2023-02-17 08:54:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 368 ms / 3,000 ms
コード長 597 bytes
コンパイル時間 302 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 265,760 KB
最終ジャッジ日時 2024-07-19 05:19:29
合計ジャッジ時間 11,863 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt, ceil
def Sieve(n):
    lst = [True] * (n + 1)
    S = []
    for i in range(2, ceil(sqrt(n)) + 1):
        if lst[i]:
            for j in range(2 * i, n + 1, i):
                lst[j] = False
    for i in range(2, n + 1):
        if lst[i]:
            S.append(i)
    return S

N = int(input())
A = list(map(int, input().split()))
M = max(A)
D = [0] * (M + 1)

for p in Sieve(M):
    now = p
    while now <= M:
        for i in range(now, M + 1, now):
            D[i] += 1
        now *= p

ans = 0
for a in A:
    ans ^= D[a]

print("white") if ans else print("black")
0