結果
| 問題 |
No.103 素因数ゲーム リターンズ
|
| コンテスト | |
| ユーザー |
Eguy
|
| 提出日時 | 2022-07-17 12:48:40 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 51 ms / 5,000 ms |
| コード長 | 1,225 bytes |
| コンパイル時間 | 127 ms |
| コンパイル使用メモリ | 82,256 KB |
| 実行使用メモリ | 65,152 KB |
| 最終ジャッジ日時 | 2024-06-29 13:50:09 |
| 合計ジャッジ時間 | 2,099 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 20 |
ソースコード
import sys, math
sys.setrecursionlimit(1000000)
INF = 1 << 100
#mod = 1000000007
mod = 998244353
input = lambda: sys.stdin.readline().rstrip()
li = lambda: list(map(int, input().split()))
def min_factors(N):
N += 1
min_fact = [i for i in range(N)]
min_fact[0] = min_fact[1] = -1
for i in range(2, N):
if not min_fact[i] == i:
continue
for j in range(i, N, i):
if min_fact[j] == j:
min_fact[j] = i
return min_fact
from collections import defaultdict
def factorization(x, min_fact):
dic = defaultdict(int)
while x > 1:
dic[min_fact[x]] += 1
x //= min_fact[x]
ret = [(i, j) for i, j in dic.items()]
return ret
def f(cnt):
lst = [0] * (cnt+1)
lst[0] = 0
for i in range(1, cnt+1):
tmp = [0] * 4
for j in range(1, 3):
if i - j >= 0:
tmp[lst[i-j]] = 1
for k in range(4):
if not tmp[k]:
lst[i] = k
break
return lst[-1]
mf = min_factors(10**4)
N = int(input())
M = li()
x = 0
for m in M:
dic = factorization(m, mf)
for _, v in dic:
x ^= f(v)
if x:
print('Alice')
else:
print('Bob')
Eguy