結果

問題 No.103 素因数ゲーム リターンズ
ユーザー AEnAEn
提出日時 2023-03-14 14:52:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 433 ms / 5,000 ms
コード長 807 bytes
コンパイル時間 171 ms
コンパイル使用メモリ 81,696 KB
実行使用メモリ 70,572 KB
最終ジャッジ日時 2023-10-18 11:41:03
合計ジャッジ時間 12,421 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 430 ms
70,572 KB
testcase_01 AC 428 ms
70,572 KB
testcase_02 AC 428 ms
70,572 KB
testcase_03 AC 427 ms
70,572 KB
testcase_04 AC 428 ms
70,572 KB
testcase_05 AC 428 ms
70,572 KB
testcase_06 AC 431 ms
70,572 KB
testcase_07 AC 431 ms
70,572 KB
testcase_08 AC 429 ms
70,572 KB
testcase_09 AC 433 ms
70,572 KB
testcase_10 AC 429 ms
70,572 KB
testcase_11 AC 427 ms
70,572 KB
testcase_12 AC 428 ms
70,572 KB
testcase_13 AC 429 ms
70,572 KB
testcase_14 AC 427 ms
70,572 KB
testcase_15 AC 427 ms
70,572 KB
testcase_16 AC 428 ms
70,572 KB
testcase_17 AC 427 ms
70,572 KB
testcase_18 AC 428 ms
70,572 KB
testcase_19 AC 430 ms
70,572 KB
testcase_20 AC 429 ms
70,572 KB
testcase_21 AC 429 ms
70,572 KB
testcase_22 AC 427 ms
70,572 KB
testcase_23 AC 429 ms
70,572 KB
testcase_24 AC 428 ms
70,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
def sieve_of_eratosthenes(n):
    prime = [True]*(n+1)
    prime[0] = False
    prime[1] = False
    sqrt_n = math.ceil(math.sqrt(n))
    for i in range(2, sqrt_n+1):
        if prime[i]:
            for j in range(2*i, n+1, i):
                prime[j] = False
    return prime

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

grundy = [0]*(10**4+1)
p = sieve_of_eratosthenes(10**4)
prime = []
for i in range(len(p)):
    if p[i]:
        prime.append(i)
    
for i in range(2,10**4+1):
    s = set()
    for pp in prime:
        if i%pp==0:
            s.add(grundy[i//pp])
        if i%(pp*pp)==0:
            s.add(grundy[i//pp//pp])
    g = 0
    while g in s:
        g += 1
    grundy[i] = g

res = 0
for m in M:
    res ^= grundy[m]
if res:
    print('Alice')
else:
    print('Bob')
0