結果

問題 No.314 ケンケンパ
ユーザー sugarrr
提出日時 2018-01-04 18:05:31
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 28 ms / 1,000 ms
コード長 594 bytes
コンパイル時間 705 ms
コンパイル使用メモリ 67,652 KB
実行使用メモリ 26,624 KB
最終ジャッジ日時 2024-12-23 03:44:41
合計ジャッジ時間 1,651 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #



#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
typedef long long ll;
using namespace std;

int mod(long long int a){
    return a%((int)pow(10,9)+7);
}

int main(){
    int n;cin>>n;
    long long int dp[3][n];
    dp[0][1]=0;dp[1][1]=1;dp[2][1]=0;
    for(int j=2;j<=n;j++){
        dp[0][j]=mod(dp[1][j-1]+dp[2][j-1]);
        dp[1][j]=mod(dp[0][j-1]);
        dp[2][j]=mod(dp[1][j-1]);
    }
    cout<<mod(dp[0][n]+dp[1][n]+dp[2][n])<<endl;
    return 0;
}
0