結果

問題 No.7 プライムナンバーゲーム
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-04-12 21:18:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 58 ms / 5,000 ms
コード長 456 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 82,420 KB
実行使用メモリ 64,896 KB
最終ジャッジ日時 2024-04-09 05:03:17
合計ジャッジ時間 1,807 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,436 KB
testcase_01 AC 36 ms
52,572 KB
testcase_02 AC 58 ms
64,344 KB
testcase_03 AC 48 ms
64,784 KB
testcase_04 AC 45 ms
61,764 KB
testcase_05 AC 45 ms
61,472 KB
testcase_06 AC 51 ms
64,780 KB
testcase_07 AC 50 ms
64,120 KB
testcase_08 AC 51 ms
64,508 KB
testcase_09 AC 53 ms
63,904 KB
testcase_10 AC 36 ms
52,836 KB
testcase_11 AC 52 ms
63,592 KB
testcase_12 AC 55 ms
63,172 KB
testcase_13 AC 55 ms
64,252 KB
testcase_14 AC 58 ms
63,160 KB
testcase_15 AC 56 ms
63,344 KB
testcase_16 AC 57 ms
64,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

primes = []

for i in range(2,n+1):
    check = True
    for p in primes:
        if p**2 > i:
            break
        if i%p == 0:
            check = False
            break
    if check:
        primes.append(i)

dp = [0]*(n+1)
dp[0] = dp[1] = 1
for i in range(2,n+1):
    for j in primes:
        if i-j < 0:
            break
        if dp[i-j] == 0:
            dp[i] = 1
            break

print("Win" if dp[-1] == 1 else "Lose")
0