結果
問題 |
No.7 プライムナンバーゲーム
|
ユーザー |
![]() |
提出日時 | 2020-01-30 17:03:31 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 686 ms / 5,000 ms |
コード長 | 676 bytes |
コンパイル時間 | 79 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,392 KB |
最終ジャッジ日時 | 2024-10-01 16:30:43 |
合計ジャッジ時間 | 5,475 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
ソースコード
n=int(input()) def eratosthenes(limit): import math A=[i for i in range(2,limit+1)] P=[] while True: prime=min(A) if prime>math.sqrt(limit): break P.append(prime) i=0 while i<len(A): if A[i]%prime==0: A.pop(i) continue i+=1 for a in A: P.append(a) return P P=eratosthenes(n) dp=[False]*(n+1) dp[0]=dp[1]=1 for i in range(2,n+1): for p in P: if i-p>=0 and not dp[i-p]: dp[i]=True break else: dp[i]=False print('Win') if dp[n] else print('Lose')