結果

問題 No.103 素因数ゲーム リターンズ
ユーザー 👑 rin204rin204
提出日時 2022-07-04 15:12:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 84 ms / 5,000 ms
コード長 935 bytes
コンパイル時間 1,404 ms
コンパイル使用メモリ 87,068 KB
実行使用メモリ 78,268 KB
最終ジャッジ日時 2023-08-20 22:32:53
合計ジャッジ時間 3,834 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
77,784 KB
testcase_01 AC 77 ms
78,152 KB
testcase_02 AC 77 ms
78,080 KB
testcase_03 AC 81 ms
77,708 KB
testcase_04 AC 77 ms
77,828 KB
testcase_05 AC 77 ms
78,012 KB
testcase_06 AC 79 ms
78,156 KB
testcase_07 AC 75 ms
78,068 KB
testcase_08 AC 74 ms
77,672 KB
testcase_09 AC 77 ms
77,820 KB
testcase_10 AC 80 ms
78,064 KB
testcase_11 AC 79 ms
77,952 KB
testcase_12 AC 78 ms
77,840 KB
testcase_13 AC 78 ms
77,780 KB
testcase_14 AC 79 ms
78,268 KB
testcase_15 AC 80 ms
78,068 KB
testcase_16 AC 84 ms
77,636 KB
testcase_17 AC 82 ms
77,708 KB
testcase_18 AC 79 ms
78,064 KB
testcase_19 AC 81 ms
77,844 KB
testcase_20 AC 80 ms
78,156 KB
testcase_21 AC 79 ms
77,712 KB
testcase_22 AC 82 ms
77,908 KB
testcase_23 AC 78 ms
78,060 KB
testcase_24 AC 79 ms
77,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = 200000
div = [i for i in range(N)]
for i in range(2, int(N ** 0.5 + 1)):
    if div[i] != i:
        continue
    for j in range(i * i, N, i):
        if div[j] == j:
            div[j] = i



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

memo = {():0}
def f(lst):
    tup = tuple(sorted(l for l in lst if l != 0))
    if tup in memo:
        return memo[tup]
    se = set()
    le = len(lst)
    for i in range(le):
        if lst[i] >= 1:
            lst[i] -= 1
            se.add(f(lst))
            lst[i] += 1
        if lst[i] >= 2:
            lst[i] -= 2
            se.add(f(lst))
            lst[i] += 2
    mex = 0
    while mex in se:
        mex += 1
    memo[tup] = mex
    return mex

xor = 0
for a in A:
    cnt = {}
    while a >= 2:
        cnt[div[a]] = cnt.get(div[a], 0) + 1
        a //= div[a]
    lst = sorted(cnt.values())
    xor ^= f(lst)

if xor == 0:
    print("Bob")
else:
    print("Alice")
0