結果
| 問題 |
No.7 プライムナンバーゲーム
|
| コンテスト | |
| ユーザー |
n_knuu
|
| 提出日時 | 2017-01-05 04:37:28 |
| 言語 | Nim (2.2.0) |
| 結果 |
AC
|
| 実行時間 | 21 ms / 5,000 ms |
| コード長 | 418 bytes |
| コンパイル時間 | 2,949 ms |
| コンパイル使用メモリ | 66,740 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-01 15:53:59 |
| 合計ジャッジ時間 | 3,690 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 28) Warning: imported and not used: 'algorithm' [UnusedImport] /home/judge/data/code/Main.nim(1, 18) Warning: imported and not used: 'sequtils' [UnusedImport]
ソースコード
import strutils, sequtils, algorithm
let N = stdin.readline.parseInt
var
sieve = newSeq[bool](N+1)
primes = newSeq[int]()
for i in 2..N:
if not sieve[i]:
primes.add(i)
for j in countup(2 * i, N, i):
sieve[j] = true
var dp = newSeq[bool](N+1)
dp[0] = true
dp[1] = true
for i in 2..N:
for p in primes:
if p > i:
break
dp[i] = dp[i] or not dp[i-p]
echo(if dp[N]: "Win" else: "Lose")
n_knuu