結果

問題 No.314 ケンケンパ
ユーザー hiromi-mihiromi-mi
提出日時 2018-12-31 12:10:07
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 8 ms / 1,000 ms
コード長 704 bytes
コンパイル時間 386 ms
コンパイル使用メモリ 62,396 KB
実行使用メモリ 26,760 KB
最終ジャッジ日時 2024-04-20 07:19:15
合計ジャッジ時間 1,001 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <tuple>
#include <cstdio>
#include <assert.h>

using namespace std;

typedef long long ll;


#define rep(i,b) for(ll i=0;i<(b);++i)
#define rep1(i,b) for(ll i=1;i<=(b);++i)
#define vec vector
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

int N;
#define MOD 1000000007
ll dp[1000010][3];

int main() {
   cin >> N;
   dp[0][0] = 1;
   dp[0][1] = 0;
   dp[0][2] = 0;
   rep(i, N) {
      dp[i+1][1] = dp[i][0];
      dp[i+1][2] = dp[i][1];
      dp[i+1][0] = (dp[i][2] + dp[i][1]) % MOD;
   }
   cout << ((dp[N][0] + dp[N][1] + dp[N][2]) % MOD) << endl;
}
0