結果

問題 No.103 素因数ゲーム リターンズ
ユーザー maspymaspy
提出日時 2020-03-05 14:57:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 536 ms / 5,000 ms
コード長 766 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 44,212 KB
最終ジャッジ日時 2024-04-22 02:32:43
合計ジャッジ時間 13,991 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 462 ms
44,208 KB
testcase_01 AC 462 ms
43,960 KB
testcase_02 AC 464 ms
43,824 KB
testcase_03 AC 465 ms
43,828 KB
testcase_04 AC 461 ms
43,568 KB
testcase_05 AC 460 ms
43,956 KB
testcase_06 AC 456 ms
44,204 KB
testcase_07 AC 459 ms
43,692 KB
testcase_08 AC 467 ms
43,696 KB
testcase_09 AC 454 ms
44,084 KB
testcase_10 AC 466 ms
43,704 KB
testcase_11 AC 469 ms
43,952 KB
testcase_12 AC 464 ms
44,080 KB
testcase_13 AC 458 ms
43,568 KB
testcase_14 AC 456 ms
44,212 KB
testcase_15 AC 536 ms
43,960 KB
testcase_16 AC 463 ms
43,956 KB
testcase_17 AC 458 ms
43,700 KB
testcase_18 AC 462 ms
43,956 KB
testcase_19 AC 461 ms
43,824 KB
testcase_20 AC 462 ms
44,084 KB
testcase_21 AC 460 ms
43,576 KB
testcase_22 AC 460 ms
44,208 KB
testcase_23 AC 452 ms
43,956 KB
testcase_24 AC 461 ms
43,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/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')
0