結果

問題 No.314 ケンケンパ
ユーザー nCk_cvnCk_cv
提出日時 2015-12-08 15:42:58
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 36 ms / 1,000 ms
コード長 612 bytes
コンパイル時間 481 ms
コンパイル使用メモリ 70,944 KB
実行使用メモリ 27,092 KB
最終ジャッジ日時 2023-10-12 21:54:22
合計ジャッジ時間 1,474 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
26,328 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,356 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,352 KB
testcase_14 AC 2 ms
4,352 KB
testcase_15 AC 2 ms
4,352 KB
testcase_16 AC 2 ms
4,352 KB
testcase_17 AC 6 ms
5,744 KB
testcase_18 AC 18 ms
14,824 KB
testcase_19 AC 36 ms
27,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
using namespace std;
#define ll long long

ll dp[1000001][3];
int main() {
  int N;
  cin >> N;
  dp[0][1] = 1;
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < 3; j++) {
      if(j != 2) {
        dp[i+1][j+1] += dp[i][j];
        dp[i+1][j+1] %= 1000000007;
      }
      if(j != 0) {
        dp[i+1][0] += dp[i][j];
        dp[i+1][0] %= 1000000007;
      }
    }
  }
  ll ans = (dp[N-1][0] + dp[N-1][1] + dp[N-1][2]) % 1000000007;
  cout << ans << endl;

}
0