結果

問題 No.103 素因数ゲーム リターンズ
ユーザー tnodinotnodino
提出日時 2022-06-13 18:43:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 88 ms / 5,000 ms
コード長 557 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2024-04-08 13:05:29
合計ジャッジ時間 3,060 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
10,240 KB
testcase_01 AC 82 ms
10,240 KB
testcase_02 AC 80 ms
10,240 KB
testcase_03 AC 80 ms
10,240 KB
testcase_04 AC 80 ms
10,240 KB
testcase_05 AC 80 ms
10,240 KB
testcase_06 AC 83 ms
10,240 KB
testcase_07 AC 81 ms
10,240 KB
testcase_08 AC 80 ms
10,240 KB
testcase_09 AC 81 ms
10,240 KB
testcase_10 AC 85 ms
10,240 KB
testcase_11 AC 81 ms
10,240 KB
testcase_12 AC 81 ms
10,240 KB
testcase_13 AC 82 ms
10,240 KB
testcase_14 AC 80 ms
10,240 KB
testcase_15 AC 81 ms
10,240 KB
testcase_16 AC 81 ms
10,240 KB
testcase_17 AC 80 ms
10,240 KB
testcase_18 AC 80 ms
10,240 KB
testcase_19 AC 80 ms
10,240 KB
testcase_20 AC 80 ms
10,240 KB
testcase_21 AC 80 ms
10,240 KB
testcase_22 AC 79 ms
10,240 KB
testcase_23 AC 80 ms
10,240 KB
testcase_24 AC 81 ms
10,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt
def prime_factorization(N):
    ret = {}
    for i in range(2,int(sqrt(N))+1):
        if N % i == 0:
            ret[i] = 0
            while N % i == 0:
                ret[i] += 1
                N //= i
    if N > 1:
        ret[N] = 1
    return ret

M = 10000
grundy = [0] * (M+1)
for i in range(2,M+1):
    for v in prime_factorization(i).values():
        grundy[i] ^= v % 3
N = int(input())
M = list(map(int,input().split()))
nim = 0
for i in range(N):
    nim ^= grundy[M[i]]
if nim:
    print('Alice')
else:
    print('Bob')
0