結果

問題 No.7 プライムナンバーゲーム
ユーザー kou_kkkkou_kkk
提出日時 2022-10-22 09:37:43
言語 Nim
(2.0.2)
結果
AC  
実行時間 49 ms / 5,000 ms
コード長 442 bytes
コンパイル時間 4,278 ms
コンパイル使用メモリ 71,524 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-14 05:46:32
合計ジャッジ時間 5,752 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 49 ms
4,384 KB
testcase_03 AC 5 ms
4,380 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 16 ms
4,376 KB
testcase_07 AC 11 ms
4,376 KB
testcase_08 AC 6 ms
4,380 KB
testcase_09 AC 22 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 11 ms
4,376 KB
testcase_12 AC 35 ms
4,376 KB
testcase_13 AC 38 ms
4,376 KB
testcase_14 AC 49 ms
4,380 KB
testcase_15 AC 47 ms
4,376 KB
testcase_16 AC 43 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sequtils,strutils

var
  n = parseInt readLine stdin
  a = true.repeat(n + 1)
a[0] = false
a[1] = false
for i in 2..n:
  if not a[i]: continue
  for j in countup(i * 2,n,i):
    a[j] = false
var
  ps = a.pairs.toSeq.filter(proc (x : (int,bool)) : bool = x[1]).unzip[0]
  dp = true.repeat(n + 1)
dp[0] = false
dp[1] = false
for i in 2..n:
  for j in ps:
    if j <= i and dp[i - j]:
      dp[i] = false
echo if dp[n]: "Lose" else: "Win"
0