結果

問題 No.103 素因数ゲーム リターンズ
ユーザー terasaterasa
提出日時 2022-09-26 21:04:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,580 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 86,812 KB
実行使用メモリ 77,844 KB
最終ジャッジ日時 2023-08-24 03:05:08
合計ジャッジ時間 4,894 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
77,404 KB
testcase_01 AC 112 ms
77,560 KB
testcase_02 AC 112 ms
77,264 KB
testcase_03 AC 113 ms
77,308 KB
testcase_04 AC 112 ms
77,436 KB
testcase_05 AC 111 ms
77,516 KB
testcase_06 AC 112 ms
77,632 KB
testcase_07 AC 112 ms
77,328 KB
testcase_08 AC 111 ms
77,432 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 111 ms
77,444 KB
testcase_14 AC 112 ms
77,456 KB
testcase_15 AC 113 ms
77,620 KB
testcase_16 AC 112 ms
77,412 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 112 ms
77,352 KB
testcase_22 AC 109 ms
77,456 KB
testcase_23 AC 111 ms
77,400 KB
testcase_24 AC 116 ms
77,784 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)
D = defaultdict(int)
for m in M:
    for f in osa_k.factors(m):
        D[f] += 1

acc = 0
for v in D.values():
    acc ^= grundy(v)
print('Alice' if acc > 0 else 'Bob')
0