結果

問題 No.314 ケンケンパ
ユーザー tadanoningen
提出日時 2021-01-21 00:54:51
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 90 ms / 1,000 ms
コード長 513 bytes
コンパイル時間 635 ms
コンパイル使用メモリ 75,260 KB
最終ジャッジ日時 2025-01-18 03:00:30
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>

using namespace std;
using ll = long long;

const ll mod = 1000000007;

vector<vector<ll>> dp(1000005,vector<ll>(3));

int main(){
    ll n;
    cin >> n;
    
    dp[0][0] = 1;
    for(int i=1;i <= n;i++){
        for(int j=0;j < 3;j++){
            dp[i][0] = (dp[i-1][1] + dp[i-1][2]) % mod;
            dp[i][1] = dp[i-1][0];
            dp[i][2] = dp[i-1][1];
        }
    }

    ll ans = (dp[n][0] + dp[n][1] + dp[n][2]) % mod;

    cout << ans << endl;
    return 0;
}
0