結果
問題 |
No.2 素因数ゲーム
|
ユーザー |
|
提出日時 | 2024-01-26 21:01:49 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 598 bytes |
コンパイル時間 | 694 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 114,204 KB |
最終ジャッジ日時 | 2024-09-28 07:33:17 |
合計ジャッジ時間 | 7,213 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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")