結果

問題 No.314 ケンケンパ
ユーザー misora192misora192
提出日時 2020-07-06 08:26:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 82 ms / 1,000 ms
コード長 729 bytes
コンパイル時間 1,794 ms
コンパイル使用メモリ 171,304 KB
実行使用メモリ 57,948 KB
最終ジャッジ日時 2023-10-24 22:00:45
合計ジャッジ時間 2,863 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
56,892 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 3 ms
4,348 KB
testcase_16 AC 4 ms
4,508 KB
testcase_17 AC 11 ms
8,732 KB
testcase_18 AC 41 ms
29,316 KB
testcase_19 AC 82 ms
57,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll MOD = 1e9 + 7;

	int n;
	cin >> n;

	vector<vector<ll>> dp(n+1, vector<ll>(3, 0ll));
	dp[0][0] = 1ll;
	for(int i = 1; i <= n; i++){
		dp[i][0] += dp[i-1][1] + dp[i-1][2];
		dp[i][0] %= MOD;

		dp[i][1] += dp[i-1][0];
		dp[i][1] %= MOD;

		dp[i][2] += dp[i-1][1];
		dp[i][2] %= MOD;
	}

	cout << (dp[n][0] + dp[n][1] + dp[n][2]) % MOD << endl;
}
0