結果

問題 No.7 プライムナンバーゲーム
ユーザー ntudantuda
提出日時 2022-10-31 12:13:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 96 ms / 5,000 ms
コード長 588 bytes
コンパイル時間 371 ms
コンパイル使用メモリ 87,232 KB
実行使用メモリ 76,756 KB
最終ジャッジ日時 2023-09-22 09:45:49
合計ジャッジ時間 2,817 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,704 KB
testcase_01 AC 74 ms
71,548 KB
testcase_02 AC 96 ms
76,484 KB
testcase_03 AC 81 ms
76,608 KB
testcase_04 AC 80 ms
76,448 KB
testcase_05 AC 77 ms
76,668 KB
testcase_06 AC 83 ms
76,504 KB
testcase_07 AC 82 ms
76,604 KB
testcase_08 AC 84 ms
76,692 KB
testcase_09 AC 86 ms
76,452 KB
testcase_10 AC 74 ms
71,464 KB
testcase_11 AC 85 ms
76,732 KB
testcase_12 AC 89 ms
76,488 KB
testcase_13 AC 90 ms
76,596 KB
testcase_14 AC 95 ms
76,432 KB
testcase_15 AC 91 ms
76,756 KB
testcase_16 AC 89 ms
76,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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]])
0