結果

問題 No.786 京都大学の過去問
ユーザー nadeshinonadeshino
提出日時 2019-02-22 21:17:02
言語 Nim
(2.0.2)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,028 bytes
コンパイル時間 4,609 ms
コンパイル使用メモリ 67,864 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 11:59:10
合計ジャッジ時間 4,515 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 19) Warning: Use the new 'sugar' module instead; future is deprecated [Deprecated]
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'algorithm' [UnusedImport]
/home/judge/data/code/Main.nim(1, 19) Warning: imported and not used: 'future' [UnusedImport]
/home/judge/data/code/Main.nim(1, 27) Warning: imported and not used: 'hashes' [UnusedImport]
/home/judge/data/code/Main.nim(1, 43) Warning: imported and not used: 'math' [UnusedImport]

ソースコード

diff #

import algorithm, future, hashes, macros, math, sequtils, sets, strutils, tables, unicode

template readString: string = stdin.readLine
template readStrings: seq[string] = stdin.readLine.split
template readInt: int = stdin.readLine.parseInt
template readInts: seq[int] = stdin.readLine.split.map(parseInt)
template readFloat: float = stdin.readLine.parseFloat
template readFloats: seq[float] = stdin.readLine.split.map(parseFloat)
template times(n: int, body: untyped): untyped = (for _ in 0..<n: body)
proc newSeq2[T](n1, n2: Natural): seq[seq[T]] = newSeqWith(n1, newSeq[T](n2))
proc newSeq3[T](n1, n2, n3: Natural): seq[seq[seq[T]]] = newSeqWith(n1, newSeqWith(n2, newSeq[T](n3)))

macro unpack*(rhs: seq, cnt: static[int]): auto =
  let t = genSym(); result = quote do:(let `t` = `rhs`;())
  for i in 0..<cnt: result[0][1].add(quote do:`t`[`i`])

# -------------------------------------------------- #

var N = readInt
var dp = newSeq[int](N + 1)
dp[1] = 1
dp[2] = 2
for i in 3..N:
  dp[i] = dp[i - 1] + dp[i - 2]
echo dp[N]
0