結果

問題 No.7 プライムナンバーゲーム
ユーザー n_knuun_knuu
提出日時 2017-01-05 04:37:43
言語 Nim
(2.0.2)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 455 bytes
コンパイル時間 3,020 ms
コンパイル使用メモリ 65,304 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-09 04:09:19
合計ジャッジ時間 3,838 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,948 KB
testcase_02 AC 12 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,948 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 5 ms
6,944 KB
testcase_07 AC 4 ms
6,944 KB
testcase_08 AC 3 ms
6,944 KB
testcase_09 AC 6 ms
6,944 KB
testcase_10 AC 1 ms
6,948 KB
testcase_11 AC 4 ms
6,944 KB
testcase_12 AC 9 ms
6,944 KB
testcase_13 AC 10 ms
6,944 KB
testcase_14 AC 12 ms
6,948 KB
testcase_15 AC 12 ms
6,948 KB
testcase_16 AC 10 ms
6,948 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(2, 28) Warning: imported and not used: 'algorithm' [UnusedImport]
/home/judge/data/code/Main.nim(2, 18) Warning: imported and not used: 'sequtils' [UnusedImport]

ソースコード

diff #

{.checks: off, optimization: speed.}
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")
0