結果

問題 No.314 ケンケンパ
ユーザー YutaroYamanakaYutaroYamanaka
提出日時 2019-06-14 16:05:17
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 48 ms / 1,000 ms
コード長 529 bytes
コンパイル時間 365 ms
コンパイル使用メモリ 53,848 KB
実行使用メモリ 26,880 KB
最終ジャッジ日時 2024-04-25 11:48:32
合計ジャッジ時間 2,056 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
26,752 KB
testcase_01 AC 46 ms
26,880 KB
testcase_02 AC 45 ms
26,880 KB
testcase_03 AC 48 ms
26,752 KB
testcase_04 AC 45 ms
26,752 KB
testcase_05 AC 46 ms
26,752 KB
testcase_06 AC 45 ms
26,624 KB
testcase_07 AC 46 ms
26,880 KB
testcase_08 AC 45 ms
26,880 KB
testcase_09 AC 45 ms
26,752 KB
testcase_10 AC 46 ms
26,880 KB
testcase_11 AC 46 ms
26,752 KB
testcase_12 AC 47 ms
26,752 KB
testcase_13 AC 46 ms
26,752 KB
testcase_14 AC 46 ms
26,752 KB
testcase_15 AC 44 ms
26,752 KB
testcase_16 AC 44 ms
26,752 KB
testcase_17 AC 45 ms
26,752 KB
testcase_18 AC 45 ms
26,880 KB
testcase_19 AC 46 ms
26,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
typedef long long ll;

int N;
ll dp[10000010][3];
ll mod = 1000000007;

int main(void){
    // Your code here!
    cin >> N;
    for(int i = 0; i <= 1000009; i++) for(int j = 0; j < 2; j++) dp[i][j] = 0;
    dp[0][0] = 1;
    
    for(int i = 0; i <= 1000009; i++){
        dp[i+1][0] += ((dp[i][2] + dp[i][1]) % mod);
        dp[i+1][1] += (dp[i][0] % mod);
        dp[i+1][2] += (dp[i][1] % mod);
    }
    
    ll sum = dp[N][0] + dp[N][1] + dp[N][2];
    cout << sum % mod << endl;
}
0