結果

問題 No.314 ケンケンパ
ユーザー n_knuun_knuu
提出日時 2016-04-02 14:33:04
言語 Nim
(2.0.2)
結果
AC  
実行時間 219 ms / 1,000 ms
コード長 337 bytes
コンパイル時間 3,728 ms
コンパイル使用メモリ 68,836 KB
実行使用メモリ 93,372 KB
最終ジャッジ日時 2023-09-12 00:12:50
合計ジャッジ時間 5,795 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 169 ms
78,008 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 5 ms
4,776 KB
testcase_17 AC 21 ms
10,580 KB
testcase_18 AC 91 ms
40,336 KB
testcase_19 AC 219 ms
93,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils, sequtils, math
let
  N = stdin.readline.parseInt
  m = 1e9.int64 + 7.int64
var
  dp = newSeqWith(N+1, newSeqWith(3, 0.int64))
dp[0][0] = 1.int64
for i in 0..<N:
  dp[i+1][0] += dp[i][1] + dp[i][2]
  dp[i+1][1] += dp[i][0]
  dp[i+1][2] += dp[i][1]
  for j in 0..2:
    dp[i+1][j] = dp[i+1][j] mod m
echo(dp[N].sum mod m)
0