結果
| 問題 |
No.7 プライムナンバーゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-06-21 11:20:55 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 465 bytes |
| コンパイル時間 | 208 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 12,416 KB |
| 最終ジャッジ日時 | 2024-06-22 22:47:27 |
| 合計ジャッジ時間 | 1,588 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 RE * 12 |
ソースコード
N = int(input())
hurui = set(range(2, N+1))
for i in range(2, N+1):
for j in range(i*2, N+1, i):
hurui.discard(j)
dp = [-1]*(N+10)
dp[0] = 0
dp[1] = 0
def grundy(x):
if dp[x] != -1:
return dp[x]
s = set()
for i in range(2, x+1):
if i in hurui:
s.add(grundy(x-i))
for i in range(x+1):
if i not in s:
dp[x] = i
return i
if grundy(N)&1:
print("Lose")
else:
print("Win")