結果

問題 No.314 ケンケンパ
ユーザー tunamagur0tunamagur0
提出日時 2019-09-28 22:23:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 14 ms / 1,000 ms
コード長 432 bytes
コンパイル時間 1,522 ms
コンパイル使用メモリ 162,940 KB
実行使用メモリ 26,856 KB
最終ジャッジ日時 2024-04-14 07:02:59
合計ジャッジ時間 2,508 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
26,484 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 4 ms
6,944 KB
testcase_18 AC 8 ms
14,816 KB
testcase_19 AC 14 ms
26,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define MOD ((long long)(1e9 + 7))

int main(void) {
  int N;
  cin >> N;
  long long dp[N][3] = {};
  dp[0][1] = 1;
  for (int i = 1; i < N; i++) {
    dp[i][0] = (dp[i - 1][2] + dp[i - 1][1]) % MOD;
    dp[i][1] = (dp[i - 1][0]) % MOD;
    dp[i][2] = (dp[i - 1][1]) % MOD;
  }
  long long ans = (dp[N - 1][0] + dp[N - 1][1] + dp[N - 1][2]) % MOD;
  cout << ans << endl;

  return 0;
}
0