結果
| 問題 |
No.2 素因数ゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-01-26 20:59:49 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 598 bytes |
| コンパイル時間 | 249 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 852,720 KB |
| 最終ジャッジ日時 | 2024-09-28 07:33:07 |
| 合計ジャッジ時間 | 11,723 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 9 MLE * 1 -- * 21 |
ソースコード
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")