結果
| 問題 | No.2 素因数ゲーム |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-01-26 21:01:49 |
| 言語 | Python3 (3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL) |
| 結果 |
TLE
不安定
|
| 実行時間 | - |
| コード長 | 598 bytes |
| 記録 | |
| コンパイル時間 | 280 ms |
| コンパイル使用メモリ | 21,336 KB |
| 実行使用メモリ | 112,020 KB |
| 最終ジャッジ日時 | 2026-09-05 14:52:10 |
| 合計ジャッジ時間 | 10,512 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 TLE * 1 -- * 24 |
ソースコード
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")