結果

問題 No.2 素因数ゲーム
ユーザー NoneNone
提出日時 2020-09-22 23:24:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 100 ms / 5,000 ms
コード長 1,706 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 86,928 KB
実行使用メモリ 76,808 KB
最終ジャッジ日時 2023-09-09 06:43:54
合計ジャッジ時間 4,601 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
71,528 KB
testcase_01 AC 90 ms
71,820 KB
testcase_02 AC 90 ms
71,840 KB
testcase_03 AC 92 ms
71,596 KB
testcase_04 AC 91 ms
71,540 KB
testcase_05 AC 90 ms
71,672 KB
testcase_06 AC 92 ms
71,968 KB
testcase_07 AC 92 ms
71,724 KB
testcase_08 AC 98 ms
76,520 KB
testcase_09 AC 91 ms
71,548 KB
testcase_10 AC 91 ms
71,720 KB
testcase_11 AC 92 ms
71,744 KB
testcase_12 AC 93 ms
71,388 KB
testcase_13 AC 94 ms
71,696 KB
testcase_14 AC 92 ms
71,680 KB
testcase_15 AC 100 ms
76,808 KB
testcase_16 AC 99 ms
76,692 KB
testcase_17 AC 93 ms
71,892 KB
testcase_18 AC 93 ms
71,744 KB
testcase_19 AC 97 ms
76,716 KB
testcase_20 AC 97 ms
76,720 KB
testcase_21 AC 97 ms
76,540 KB
testcase_22 AC 98 ms
76,436 KB
testcase_23 AC 91 ms
71,740 KB
testcase_24 AC 99 ms
76,740 KB
testcase_25 AC 97 ms
76,688 KB
testcase_26 AC 93 ms
71,680 KB
testcase_27 AC 90 ms
71,820 KB
testcase_28 AC 90 ms
71,844 KB
testcase_29 AC 91 ms
71,728 KB
testcase_30 AC 98 ms
76,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def mex(array):
    i = 0
    while i in array:
        i += 1
    return i

def solve(NN):
    """ NN: kの最大値(大雑把に遷移可能回数の最大値) """
    grundy = defaultdict(lambda: -1)
    for k in range(NN+1):
        for p in data_set(k):
            grundy[p] = mex(list(grundy[q] for q in next_set(p)))
    return grundy

def solve2(NN):
    """ 一次元専用 """
    grundy = [-1]*(NN+1)
    for p in range(NN+1):
        grundy[p] = mex(list(grundy[q] for q in next_set(p)))
    return grundy

def zeros(grundy):
    tmp = set()
    for k in range(len(grundy)):
        for p in data_set(k):
            if not grundy[p]:
                tmp.add(p)
    return sorted(list(tmp))

def Sprague_Grundy(NN, array):
    """ N 個の部分不偏ゲームを並行して行うような不偏ゲーム """
    grundy = solve(NN)
    tmp = 0
    for p in array:
        tmp ^= grundy[p]
    return tmp


####( 問題毎に設定 )##################################################

def data_set(k):
    """ 有限ゲームなので、何かの変数は単調減数となっている。これを k とする。"""
    yield k

def next_set(p):
    tmp = set()
    for i in range(1, p+1):
        if p-i>=0:
            tmp.add(p-i)
    return tmp

####################################################################

def prime_factors(n):
    i = 2
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            yield i
    if n > 1:
        yield n

from collections import defaultdict
from collections import Counter

N = int(input())
d = Counter(prime_factors(N))
A = list(d.values())
print("Alice" if Sprague_Grundy(max(A),A)!=0 else "Bob")
0