結果
| 問題 |
No.7 プライムナンバーゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-07-30 21:25:41 |
| 言語 | Nim (2.2.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 848 bytes |
| コンパイル時間 | 910 ms |
| コンパイル使用メモリ | 70,092 KB |
| 最終ジャッジ日時 | 2024-11-14 20:10:40 |
| 合計ジャッジ時間 | 1,253 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、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
ソースコード
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 getIsPrimes(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
proc getPrimes():seq[int] =
const isPrime = getIsPrimes(10000)
result = newSeq[int](0)
for i,p in isPrime:
if p : result.add(i)
# lose 2 3 ... <=> win 0 1 4 5 6 7 ...
const primes = getPrimes()
let N = get().parseInt
var win = newSeqWith(N,false)
win[0] = true
win[1] = true
for i in 2..N:
for p in primes:
if i - p < 0 : break
if not win[i-p]:
win[i] = true
break
echo if win[N]: "Win" else: "Lose"