結果

問題 No.7 プライムナンバーゲーム
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-04-12 21:10:43
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 435 bytes
コンパイル時間 338 ms
コンパイル使用メモリ 87,120 KB
実行使用メモリ 76,788 KB
最終ジャッジ日時 2023-09-11 02:20:45
合計ジャッジ時間 2,888 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,040 KB
testcase_01 WA -
testcase_02 AC 93 ms
76,520 KB
testcase_03 AC 92 ms
76,500 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 85 ms
76,400 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 70 ms
71,452 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 92 ms
76,352 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 93 ms
76,472 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)
for i in range(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] else "Lose")
0