結果

問題 No.314 ケンケンパ
コンテスト
ユーザー siman
提出日時 2016-03-22 20:28:37
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 16 ms / 1,000 ms
コード長 754 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 500 ms
コンパイル使用メモリ 96,120 KB
実行使用メモリ 27,008 KB
最終ジャッジ日時 2026-04-17 14:39:38
合計ジャッジ時間 1,451 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <limits.h>
#include <time.h>
#include <string>
#include <string.h>
#include <sstream>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;

const int KEN = 0;
const int PAR = 1;
const int KENKEN = 2;
const ll MOD = 1000000007;

int main(){
  ll n;
  cin >> n;

  ll dp[n+1][3];
  memset(dp, 0, sizeof(dp));
  dp[1][KEN] = 1;

  for(ll i = 2; i <= n; i++){
    dp[i][KEN] = dp[i-1][PAR] % MOD;
    dp[i][PAR] = (dp[i-1][KEN] + dp[i-1][KENKEN]) % MOD;
    dp[i][KENKEN] = dp[i-1][KEN] % MOD;
  }

  cout << (dp[n][KEN] + dp[n][PAR] + dp[n][KENKEN]) % MOD << endl;

  return 0;
}
0