結果
問題 | No.103 素因数ゲーム リターンズ |
ユーザー | warashi |
提出日時 | 2015-02-11 02:18:51 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 982 ms / 5,000 ms |
コード長 | 1,274 bytes |
コンパイル時間 | 97 ms |
コンパイル使用メモリ | 11,024 KB |
実行使用メモリ | 17,168 KB |
最終ジャッジ日時 | 2023-09-05 23:09:39 |
合計ジャッジ時間 | 4,368 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 21 ms
8,772 KB |
testcase_01 | AC | 21 ms
8,648 KB |
testcase_02 | AC | 21 ms
8,616 KB |
testcase_03 | AC | 21 ms
8,736 KB |
testcase_04 | AC | 21 ms
8,716 KB |
testcase_05 | AC | 22 ms
8,684 KB |
testcase_06 | AC | 20 ms
8,728 KB |
testcase_07 | AC | 21 ms
8,752 KB |
testcase_08 | AC | 20 ms
8,604 KB |
testcase_09 | AC | 21 ms
8,756 KB |
testcase_10 | AC | 21 ms
8,784 KB |
testcase_11 | AC | 23 ms
8,648 KB |
testcase_12 | AC | 97 ms
9,860 KB |
testcase_13 | AC | 97 ms
9,960 KB |
testcase_14 | AC | 207 ms
11,156 KB |
testcase_15 | AC | 177 ms
10,852 KB |
testcase_16 | AC | 23 ms
8,792 KB |
testcase_17 | AC | 349 ms
12,472 KB |
testcase_18 | AC | 32 ms
8,860 KB |
testcase_19 | AC | 982 ms
17,168 KB |
testcase_20 | AC | 37 ms
9,136 KB |
testcase_21 | AC | 81 ms
9,736 KB |
testcase_22 | AC | 34 ms
9,100 KB |
testcase_23 | AC | 50 ms
9,228 KB |
testcase_24 | AC | 78 ms
9,472 KB |
ソースコード
#!/usr/bin/env python3 from collections import defaultdict from functools import lru_cache from itertools import count, takewhile def prime(): prime = [] def _isPrime(n): for d in takewhile(lambda x: x * x <= n, prime): if n % d == 0: return False return True for i in count(2): if _isPrime(i): prime.append(i) yield(i) @lru_cache(maxsize=None) def prime_factorization(n): factor = defaultdict(int) for p in takewhile(lambda x: x * x <= n, prime()): while n % p == 0: n //= p factor[p] += 1 if n > 1: factor[n] += 1 return factor @lru_cache(maxsize=None) def nim(nums): if sum(nums) == 0: True for i in range(len(nums)): for j in (2, 1): if nums[i] < j: continue tmp = list(nums) tmp[i] -= j tmp.sort(reverse=True) if nim(tuple(tmp)): return False return True N = int(input()) M = [int(x) for x in input().split()] init = [] for m in M: init.extend(prime_factorization(m).values()) init = [x % 3 for x in init] init.sort(reverse=True) if nim(tuple(init)): print("Bob") else: print("Alice")