結果

問題 No.314 ケンケンパ
ユーザー aleutra
提出日時 2019-06-17 07:21:56
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 74 ms / 1,000 ms
コード長 724 bytes
コンパイル時間 1,162 ms
コンパイル使用メモリ 86,240 KB
実行使用メモリ 57,772 KB
最終ジャッジ日時 2024-11-26 08:12:08
合計ジャッジ時間 1,578 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

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

    vector<vector<ll>> dp(N+10,vector<ll>(3));
    dp[0][0]=1;
    for(int i=1;i<=N;i++){
        dp[i][0]=(dp[i-1][1]+dp[i-1][2])%MOD;
        dp[i][1]=(dp[i-1][0])%MOD;
        dp[i][2]=(dp[i-1][1])%MOD;
    }

    ll ans=0;
    for(int i=0;i<3;i++){
        ans=(ans+dp[N][i])%MOD;
    }

    cout << ans << endl;

    return 0;
}
0