結果
| 問題 | No.103 素因数ゲーム リターンズ | 
| コンテスト | |
| ユーザー |  maspy | 
| 提出日時 | 2020-03-05 14:57:45 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 486 ms / 5,000 ms | 
| コード長 | 766 bytes | 
| コンパイル時間 | 173 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 44,464 KB | 
| 最終ジャッジ日時 | 2024-10-14 01:15:01 | 
| 合計ジャッジ時間 | 14,946 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 5 | 
| other | AC * 20 | 
ソースコード
#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
from collections import defaultdict
from functools import reduce
from operator import xor
# %%
N, *M = map(int, read().split())
# %%
U = 10 ** 4 + 10
pf = np.arange(U, dtype=np.int64)
for p in range(2, U):
    if pf[p] == p:
        pf[p * p::p] = p
# %%
def factor(N):
    while N > 1:
        p = pf[N]
        N //= p
        yield p
# %%
def calc_grundy(M):
    count = defaultdict(int)
    for p in factor(M):
        count[p] += 1
    xor = 0
    for x in count.values():
        xor ^= (x % 3)
    return xor
# %%
xor = reduce(xor, map(calc_grundy, M))
print('Alice' if xor else 'Bob')
            
            
            
        