結果
| 問題 | No.103 素因数ゲーム リターンズ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-02-10 11:37:51 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,069 bytes |
| コンパイル時間 | 78 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 128,240 KB |
| 最終ジャッジ日時 | 2024-06-23 16:58:01 |
| 合計ジャッジ時間 | 7,129 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 7 TLE * 1 -- * 12 |
ソースコード
#!/usr/bin/env python3
import functools
import sys
import time
from collections import defaultdict
def prime_factorization(n):
factor = defaultdict(int)
i = 2
while i * i <= n:
while n % i == 0:
n = n // i
factor[i] += 1
i += 1
if n > 1:
factor[n] += 1
return factor
def Bob_win(nums):
if len(list(filter(lambda x: x > 1, nums))) > 0:
return False
if nums.count(1) % 2 == 0:
return True
return False
@functools.lru_cache(maxsize=None)
def nim(nums):
if Bob_win(nums) == 0:
True
for i in range(len(nums)):
for j in (1, 2):
if j > nums[i]:
continue
tmp = list(nums)
tmp[i] -= j
if nim(tuple(sorted(tmp))):
return False
return True
t = time.process_time()
N = int(input())
M = [int(x) for x in input().split()]
init = []
for m in M:
init.extend(sorted(prime_factorization(m).values()))
if nim(tuple(sorted(init))):
print("Bob")
else:
print("Alice")