結果

問題 No.2 素因数ゲーム
ユーザー hodash4hodash4
提出日時 2024-01-26 20:59:49
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 598 bytes
コンパイル時間 333 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 848,568 KB
最終ジャッジ日時 2024-01-26 21:00:02
合計ジャッジ時間 11,993 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
55,732 KB
testcase_01 AC 42 ms
55,732 KB
testcase_02 AC 41 ms
55,732 KB
testcase_03 AC 49 ms
62,084 KB
testcase_04 AC 54 ms
64,324 KB
testcase_05 AC 142 ms
77,120 KB
testcase_06 AC 2,201 ms
172,796 KB
testcase_07 AC 4,385 ms
187,108 KB
testcase_08 AC 1,671 ms
176,752 KB
testcase_09 MLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
import math

def mex(arr):
    N=len(arr)
    used=[False]*(N+1)
    for e in arr:
        if 0<=e<N+1:
            used[e]=True
    for i,e in enumerate(used):
        if not e:
            return i

N=int(input())
primes=defaultdict(int)

c=N
for p in range(2,math.ceil(N//2)+1):
	while c%p==0:
		c//=p
		primes[p]+=1
if c!=1:
	primes[c]+=1



grundy = [0]*(N+1)
for i in range(2,N+1):
	arr=[]
	for p,c_lmt in primes.items():
		cp=i
		while cp%p==0:
			cp//=p
			arr.append(grundy[cp])
	grundy[i] = mex(arr)

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

0