結果

問題 No.103 素因数ゲーム リターンズ
ユーザー terasaterasa
提出日時 2022-09-26 21:08:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 113 ms / 5,000 ms
コード長 1,592 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 87,096 KB
実行使用メモリ 77,428 KB
最終ジャッジ日時 2023-08-24 03:05:17
合計ジャッジ時間 4,371 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
77,288 KB
testcase_01 AC 102 ms
77,384 KB
testcase_02 AC 105 ms
77,416 KB
testcase_03 AC 108 ms
77,260 KB
testcase_04 AC 102 ms
77,352 KB
testcase_05 AC 100 ms
77,300 KB
testcase_06 AC 105 ms
77,320 KB
testcase_07 AC 104 ms
77,392 KB
testcase_08 AC 104 ms
77,312 KB
testcase_09 AC 104 ms
77,284 KB
testcase_10 AC 105 ms
77,148 KB
testcase_11 AC 106 ms
77,272 KB
testcase_12 AC 106 ms
77,308 KB
testcase_13 AC 103 ms
77,304 KB
testcase_14 AC 107 ms
77,260 KB
testcase_15 AC 103 ms
77,428 KB
testcase_16 AC 102 ms
77,408 KB
testcase_17 AC 113 ms
77,364 KB
testcase_18 AC 105 ms
77,296 KB
testcase_19 AC 105 ms
77,392 KB
testcase_20 AC 105 ms
77,396 KB
testcase_21 AC 106 ms
77,136 KB
testcase_22 AC 107 ms
77,272 KB
testcase_23 AC 106 ms
77,316 KB
testcase_24 AC 108 ms
77,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
import sys
# import pypyjit
import itertools
import heapq
import math
from collections import deque, defaultdict
from functools import lru_cache

# for AtCoder Easy test
if __file__ == 'prog.py':
    pass
else:
    sys.setrecursionlimit(10 ** 6)
# pypyjit.set_param('max_unroll_recursion=-1')

input = sys.stdin.readline


def readints(): return map(int, input().split())
def readlist(): return list(readints())
def readstr(): return input()[:-1]


class Osa_k:
    # N以下の整数を素因数分解 O(NlogN)
    def __init__(self, N):
        self.min_factor = [i for i in range(N + 1)]
        for i in range(2, N + 1):
            if i * i > N:
                break
            if self.min_factor[i] == i:
                for j in range(2, N + 1):
                    if i * j > N:
                        break
                    if self.min_factor[i * j] > i:
                        self.min_factor[i * j] = i

    def factors(self, n):
        f = []
        while n > 1:
            f.append(self.min_factor[n])
            n //= self.min_factor[n]
        return f


@lru_cache(maxsize=None)
def grundy(n):
    if n == 0:
        return 0
    S = set()
    S.add(grundy(n - 1))
    if n >= 2:
        S.add(grundy(n - 2))

    g = 0
    while True:
        if not g in S:
            return g
        g += 1


N = int(input())
M = readlist()

osa_k = Osa_k(10 ** 4)

acc = 0
for m in M:
    D = defaultdict(int)
    for f in osa_k.factors(m):
        D[f] += 1
    for v in D.values():
        acc ^= grundy(v)
print('Alice' if acc > 0 else 'Bob')
0