結果
問題 | No.103 素因数ゲーム リターンズ |
ユーザー |
![]() |
提出日時 | 2023-03-14 14:52:02 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 441 ms / 5,000 ms |
コード長 | 807 bytes |
コンパイル時間 | 384 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 70,016 KB |
最終ジャッジ日時 | 2024-09-18 08:04:18 |
合計ジャッジ時間 | 12,592 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 20 |
ソースコード
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')