結果
問題 | No.2 素因数ゲーム |
ユーザー |
![]() |
提出日時 | 2020-03-20 19:07:52 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 827 bytes |
コンパイル時間 | 302 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,264 KB |
最終ジャッジ日時 | 2024-12-14 14:22:59 |
合計ジャッジ時間 | 3,822 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 WA * 18 |
ソースコード
import math import sys N=int(input()) def primenumber_table(N): # N以下の素数テーブル エラトステネスの篩 table=[i for i in range(2,N+1)] l=[] while len(table)!=0: num=table[0] l.append(num) i=0 while i<len(table): if table[i]%num==0: table.pop(i) else: i+=1 return l table=primenumber_table(int(math.sqrt(N))) L=[] init_N=N while N!=1: for num in table: cnt=0 while N%num==0: cnt+=1 N//=num if cnt in L: print('Bob') sys.exit() L.append(cnt) if N==init_N: L.append(1) N=1 elif N in primenumber_table(N): if 1 in L: print('Bob') sys.exit() L.append(1) N=1 grundy_num=0 for i in range(len(L)): grundy_num=grundy_num^L[i] if grundy_num!=0: print('Alice') else: print('Bob')