結果
問題 | No.7 プライムナンバーゲーム |
ユーザー |
![]() |
提出日時 | 2022-10-31 12:09:06 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 59 ms / 5,000 ms |
コード長 | 605 bytes |
コンパイル時間 | 209 ms |
コンパイル使用メモリ | 82,248 KB |
実行使用メモリ | 65,896 KB |
最終ジャッジ日時 | 2024-07-08 01:48:59 |
合計ジャッジ時間 | 1,748 ms |
ジャッジサーバーID (参考情報) |
judge4 / 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 = [0] * (N + 1) dp[0] = 1 dp[1] = 1 for i in range(2, N + 1): flag = 0 for p in PL: if i < p: break if dp[i - p] == 0: dp[i] = 1 flag = 1 break print(["Lose", "Win"][dp[N]])