結果

問題 No.1665 quotient replace
ユーザー 👑 Kazun
提出日時 2021-09-04 04:21:29
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 842 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 82,392 KB
実行使用メモリ 254,620 KB
最終ジャッジ日時 2024-12-16 04:55:41
合計ジャッジ時間 10,496 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 15 WA * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

def Smallest_Prime_Factor(N):
    """0,1,2,...,Nの最小の素因数のリスト(0,1については1にしている)
    """

    if N==0:
        return [1]

    N=abs(N)
    L=list(range(N+1))
    L[0]=L[1]=1

    x=4
    while x<=N:
        L[x]=2
        x+=2

    x=9
    while x<=N:
        if L[x]==x:
            L[x]=3
        x+=6

    x=5
    Flag=0
    while x*x<=N:
        if L[x]==x:
            y=x*x
            while y<=N:
                if L[y]==y:
                    L[y]=x
                y+=x<<1
        x+=2+2*Flag
        Flag^=1

    return L

def Grundy(x):
    g=0
    while x>1:
        x=x//L[x]
    return g
#==================================================
N=int(input())
A=list(map(int,input().split()))

L=Smallest_Prime_Factor(max(A))

G=0
for a in A:
    G^=Grundy(a)

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