結果

問題 No.314 ケンケンパ
ユーザー lioolioo
提出日時 2021-03-31 21:54:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 14 ms / 1,000 ms
コード長 451 bytes
コンパイル時間 457 ms
コンパイル使用メモリ 63,340 KB
実行使用メモリ 26,764 KB
最終ジャッジ日時 2023-08-22 01:22:12
合計ジャッジ時間 1,882 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#define MOD 1000000007

#define KEN 0
#define KK  1
#define PA  2

using namespace std;

long long int c[3][1000005]={};

int main(){
    int N;
    cin>>N;
    c[KEN][1]=1;
    for(int i=2;i<=N;i++){
        c[KEN][i]=c[PA][i-1];
        c[KK][i]=c[KEN][i-1];
        c[PA][i]=c[KEN][i-1]+c[KK][i-1]%MOD;
    }
    long long int ans=0;
    for(int i=0;i<3;i++){
        ans+=c[i][N];
        ans%=MOD;
    }
    cout<<ans<<endl;
}
0