結果
問題 |
No.7 プライムナンバーゲーム
|
ユーザー |
|
提出日時 | 2021-06-21 11:21:33 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 532 bytes |
コンパイル時間 | 125 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 13,952 KB |
最終ジャッジ日時 | 2024-06-22 22:48:08 |
合計ジャッジ時間 | 34,021 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 WA * 1 TLE * 2 |
ソースコード
import sys input = sys.stdin.readline sys.setrecursionlimit(10**6) 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")