結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,696 KB
testcase_01 AC 71 ms
71,568 KB
testcase_02 AC 90 ms
76,712 KB
testcase_03 AC 84 ms
76,324 KB
testcase_04 AC 83 ms
76,812 KB
testcase_05 AC 80 ms
76,672 KB
testcase_06 AC 88 ms
76,620 KB
testcase_07 AC 83 ms
76,676 KB
testcase_08 AC 81 ms
76,240 KB
testcase_09 AC 86 ms
76,688 KB
testcase_10 AC 70 ms
71,732 KB
testcase_11 AC 82 ms
76,572 KB
testcase_12 AC 87 ms
76,324 KB
testcase_13 AC 88 ms
76,672 KB
testcase_14 AC 89 ms
76,540 KB
testcase_15 AC 89 ms
76,768 KB
testcase_16 AC 88 ms
76,548 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 = [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]])
0