結果
| 問題 |
No.7 プライムナンバーゲーム
|
| コンテスト | |
| ユーザー |
学ぶマン
|
| 提出日時 | 2025-02-28 20:16:51 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 58 ms / 5,000 ms |
| コード長 | 489 bytes |
| コンパイル時間 | 394 ms |
| コンパイル使用メモリ | 82,040 KB |
| 実行使用メモリ | 64,228 KB |
| 最終ジャッジ日時 | 2025-02-28 20:16:54 |
| 合計ジャッジ時間 | 2,302 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
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(2, N + 1):
# 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')
学ぶマン