結果

問題 No.7 プライムナンバーゲーム
ユーザー むらためむらため
提出日時 2017-07-30 20:54:50
言語 Nim
(2.0.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 707 bytes
コンパイル時間 833 ms
コンパイル使用メモリ 59,528 KB
最終ジャッジ日時 2023-09-12 13:47:43
合計ジャッジ時間 1,356 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 50) Warning: Use the new 'sugar' module instead; future is deprecated [Deprecated]
/home/judge/data/code/Main.nim(1, 62) Error: cannot open file: queues

ソースコード

diff #

import sequtils,strutils,strscans,algorithm,math,future,sets,queues,tables
template get():string = stdin.readLine()
template times(n:int,body:untyped): untyped = (for _ in 0..<n: body)

proc getIsPrime(n:int) :seq[bool] =
  result = newSeqWith(n+1,true)
  result[0] = false
  result[1] = false
  for i in 2..n.float.sqrt.int :
    if not result[i]: continue
    for j in countup(i*2,n,i):
      result[j] = false

# lose 2 3 ... <=> win 0 1 4 5 6 7 ...
const isPrime = getIsPrime(10000)
let N = get().parseInt
var win = newSeqWith(N,false)
win[0] = true
win[1] = true
for i in 2..N:
  for j in 2..i:
    if not isPrime[j]: continue
    if not win[i-j]:
      win[i] = true
echo if win[N]: "Win" else: "Lose"
0