結果
問題 | No.7 プライムナンバーゲーム |
ユーザー |
|
提出日時 | 2020-06-01 08:32:35 |
言語 | Nim (2.2.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 841 bytes |
コンパイル時間 | 3,475 ms |
コンパイル使用メモリ | 74,240 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-21 02:23:51 |
合計ジャッジ時間 | 3,760 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | RE * 17 |
コンパイルメッセージ
/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) Warning: imported and not used: 'tables' [UnusedImport] /home/judge/data/code/Main.nim(1, 50) Warning: imported and not used: 'future' [UnusedImport] /home/judge/data/code/Main.nim(1, 26) Warning: imported and not used: 'strscans' [UnusedImport] /home/judge/data/code/Main.nim(1, 35) Warning: imported and not used: 'algorithm' [UnusedImport] /home/judge/data/code/Main.nim(1, 57) Warning: imported and not used: 'sets' [UnusedImport]
ソースコード
import sequtils,strutils,strscans,algorithm,math,future,sets,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"