結果

問題 No.7 プライムナンバーゲーム
ユーザー 学ぶマン
提出日時 2025-02-28 20:12:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 482 bytes
コンパイル時間 415 ms
コンパイル使用メモリ 82,364 KB
実行使用メモリ 63,992 KB
最終ジャッジ日時 2025-02-28 20:12:24
合計ジャッジ時間 2,221 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
cnt = [0]*(N+1)
primes = []
for i in range(2, N+1):
    if cnt[i] == 0:
        primes.append(i)
        for num in range(i, N+1, i):
            cnt[num] += 1

DP = [False] * (N + 1)
DP[0] = True
DP[1] = True

for i in range(N):
    # False に導ければ True(勝ち)
    for prime in primes:
        if prime >= i:
            break
        if not DP[i - prime]:
            DP[i] = True
            break

if DP[N]:
    print('Win')
else:
    print('Lose')
0