結果

問題 No.2 素因数ゲーム
ユーザー hodash4hodash4
提出日時 2024-01-26 21:01:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 598 bytes
コンパイル時間 181 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 113,236 KB
最終ジャッジ日時 2024-01-26 21:01:57
合計ジャッジ時間 7,623 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,112 KB
testcase_01 AC 30 ms
10,112 KB
testcase_02 AC 30 ms
10,112 KB
testcase_03 AC 32 ms
10,112 KB
testcase_04 AC 32 ms
10,112 KB
testcase_05 AC 296 ms
11,008 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
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