結果
問題 |
No.7 プライムナンバーゲーム
|
ユーザー |
![]() |
提出日時 | 2022-10-31 12:13:23 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 62 ms / 5,000 ms |
コード長 | 588 bytes |
コンパイル時間 | 189 ms |
コンパイル使用メモリ | 82,316 KB |
実行使用メモリ | 66,076 KB |
最終ジャッジ日時 | 2024-07-08 01:50:53 |
合計ジャッジ時間 | 1,817 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
ソースコード
def seachPrimeNum(N): max = int(N ** 0.5) seachList = [i for i in range(2, N + 1)] primeNum = [] while seachList[0] <= max: primeNum.append(seachList[0]) tmp = seachList[0] seachList = [i for i in seachList if i % tmp != 0] primeNum.extend(seachList) return primeNum N = int(input()) PL = seachPrimeNum(N) dp = [False] * (N + 1) dp[0] = True dp[1] = True for i in range(2, N + 1): for p in PL: if i < p: break if dp[i - p] == False: dp[i] = True break print(["Lose", "Win"][dp[N]])