結果

問題 No.103 素因数ゲーム リターンズ
ユーザー titiatitia
提出日時 2022-01-21 01:41:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 76 ms / 5,000 ms
コード長 838 bytes
コンパイル時間 460 ms
コンパイル使用メモリ 10,940 KB
実行使用メモリ 10,928 KB
最終ジャッジ日時 2023-08-16 03:44:13
合計ジャッジ時間 3,237 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
10,756 KB
testcase_01 AC 76 ms
10,556 KB
testcase_02 AC 72 ms
10,864 KB
testcase_03 AC 71 ms
10,752 KB
testcase_04 AC 72 ms
10,608 KB
testcase_05 AC 71 ms
10,460 KB
testcase_06 AC 71 ms
10,728 KB
testcase_07 AC 73 ms
10,872 KB
testcase_08 AC 71 ms
10,808 KB
testcase_09 AC 71 ms
10,488 KB
testcase_10 AC 71 ms
10,536 KB
testcase_11 AC 72 ms
10,720 KB
testcase_12 AC 71 ms
10,824 KB
testcase_13 AC 71 ms
10,724 KB
testcase_14 AC 71 ms
10,888 KB
testcase_15 AC 71 ms
10,848 KB
testcase_16 AC 71 ms
10,924 KB
testcase_17 AC 71 ms
10,888 KB
testcase_18 AC 71 ms
10,748 KB
testcase_19 AC 72 ms
10,768 KB
testcase_20 AC 72 ms
10,928 KB
testcase_21 AC 71 ms
10,764 KB
testcase_22 AC 72 ms
10,772 KB
testcase_23 AC 74 ms
10,852 KB
testcase_24 AC 72 ms
10,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

def fact(x):
    L=int(math.sqrt(x))

    FACT=dict()

    for i in range(2,L+2):
        while x%i==0:
            FACT[i]=FACT.get(i,0)+1
            x=x//i

    if x!=1:
        FACT[x]=FACT.get(x,0)+1

    return FACT


FACT=[dict() for i in range(10**4+5)]
for i in range(1,10**4+1):
    FACT[i]=fact(i)


def grundy(x):
    if x==1:
        return 0
    
    LIST=[]

    for f in FACT[x]:
        LIST.append(G[x//f])

        if (x//f)%f==0:
            LIST.append(G[x//f//f])

    SET=set(LIST)
    
    for i in range(10**9):
        if i in SET:
            continue
        else:
            G[x]=i
            break

G=[0]*(10**4+5)
for i in range(1,10**4+5):
    grundy(i)

N=int(input())
A=list(map(int,input().split()))

XOR=0

for a in A:
    XOR^=G[a]

if XOR!=0:
    print("Alice")
else:
    print("Bob")
0