結果

問題 No.314 ケンケンパ
ユーザー aleutraaleutra
提出日時 2019-06-17 07:21:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 76 ms / 1,000 ms
コード長 724 bytes
コンパイル時間 607 ms
コンパイル使用メモリ 85,928 KB
実行使用メモリ 57,764 KB
最終ジャッジ日時 2023-08-17 11:49:48
合計ジャッジ時間 1,784 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
56,760 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 4 ms
4,384 KB
testcase_17 AC 10 ms
8,688 KB
testcase_18 AC 38 ms
29,212 KB
testcase_19 AC 76 ms
57,764 KB
権限があれば一括ダウンロードができます

ソースコード

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