結果

問題 No.314 ケンケンパ
ユーザー sugarrrsugarrr
提出日時 2018-01-04 18:05:31
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 13 ms / 1,000 ms
コード長 594 bytes
コンパイル時間 704 ms
コンパイル使用メモリ 67,364 KB
実行使用メモリ 26,764 KB
最終ジャッジ日時 2023-08-24 18:58:51
合計ジャッジ時間 1,614 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
26,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 3 ms
5,700 KB
testcase_18 AC 7 ms
14,664 KB
testcase_19 AC 12 ms
26,764 KB
権限があれば一括ダウンロードができます

ソースコード

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