結果

問題 No.2 素因数ゲーム
ユーザー asumo0729asumo0729
提出日時 2023-01-18 18:25:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 134 ms / 5,000 ms
コード長 1,504 bytes
コンパイル時間 309 ms
コンパイル使用メモリ 86,924 KB
実行使用メモリ 77,828 KB
最終ジャッジ日時 2023-09-02 12:34:57
合計ジャッジ時間 5,728 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
72,752 KB
testcase_01 AC 123 ms
72,508 KB
testcase_02 AC 122 ms
72,668 KB
testcase_03 AC 123 ms
72,732 KB
testcase_04 AC 121 ms
72,448 KB
testcase_05 AC 123 ms
72,736 KB
testcase_06 AC 126 ms
77,236 KB
testcase_07 AC 125 ms
77,352 KB
testcase_08 AC 124 ms
77,236 KB
testcase_09 AC 125 ms
77,240 KB
testcase_10 AC 125 ms
77,288 KB
testcase_11 AC 123 ms
77,204 KB
testcase_12 AC 130 ms
77,340 KB
testcase_13 AC 134 ms
77,828 KB
testcase_14 AC 126 ms
77,236 KB
testcase_15 AC 129 ms
77,368 KB
testcase_16 AC 124 ms
77,036 KB
testcase_17 AC 124 ms
77,176 KB
testcase_18 AC 126 ms
76,796 KB
testcase_19 AC 126 ms
77,140 KB
testcase_20 AC 128 ms
77,124 KB
testcase_21 AC 125 ms
77,256 KB
testcase_22 AC 125 ms
77,008 KB
testcase_23 AC 126 ms
77,068 KB
testcase_24 AC 128 ms
77,132 KB
testcase_25 AC 126 ms
77,196 KB
testcase_26 AC 124 ms
77,068 KB
testcase_27 AC 126 ms
77,236 KB
testcase_28 AC 126 ms
76,848 KB
testcase_29 AC 127 ms
77,028 KB
testcase_30 AC 127 ms
77,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from operator import itemgetter
from collections import defaultdict, deque
import heapq
from heapq import heapify, heappop, _heapify_max, heappush
from bisect import bisect_left, bisect_right
import math
import itertools
import copy

stdin=sys.stdin
#sys.setrecursionlimit(10 ** 7)
#import pypyjit
#pypyjit.set_param('max_unroll_recursion=-1')

ip=lambda: int(sp())
fp=lambda: float(sp())
lp=lambda:list(map(int,stdin.readline().split()))
sp=lambda:stdin.readline().rstrip()
Yp=lambda:print('Yes')
Np=lambda:print('No')
inf = 1 << 60
mod = 10 ** 9 + 7
mod = 998244353
eps = 1e-9
sortkey1 = itemgetter(0)
sortkey2 = lambda x: (x[0], x[1])
# sort(key=lambda x:(x[1], x[2]))


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

N = ip()
NN = N
factors = set()
soin = set()
for i in range(2, N + 1):
    if i * i > N:
        break
    if N % i == 0:
        factors.add(i)
        factors.add(N//i)
    if NN % i == 0:
        soin.add(i)
        while NN % i == 0:
            NN //= i
if NN != 1:
    soin.add(NN)

factors.add(N)
factors = list(factors)
factors.sort()
grundy = defaultdict(int)
grundy[1] = 0

for fac in factors:
    mex = set()
    for f in soin:
        if fac % f == 0:
            ffac = fac
            while ffac % f == 0:
                mex.add(grundy[ffac//f])
                ffac //= f
    for i in range(100000):
        if i not in mex:
            x = i
            break
    grundy[fac] = x

if grundy[N]:
    print('Alice')
else:
    print('Bob')
0