結果

問題 No.314 ケンケンパ
ユーザー achapiachapi
提出日時 2023-04-23 09:45:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 19 ms / 1,000 ms
コード長 497 bytes
コンパイル時間 4,000 ms
コンパイル使用メモリ 256,552 KB
実行使用メモリ 18,816 KB
最終ジャッジ日時 2024-04-25 07:34:39
合計ジャッジ時間 4,720 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
18,688 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 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 2 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 3 ms
5,376 KB
testcase_18 AC 9 ms
10,752 KB
testcase_19 AC 19 ms
18,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using mint = atcoder::modint1000000007;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<vector<mint>> dp(3, vector<mint> (n + 1));
	dp[0][0] = 1;
	for (int i = 1; i < n; i++){
		for (int j = 1; j < 2; j++){
			dp[j][i] += dp[j - 1][i - 1];
		}
		for (int j = 0; j < 2; j++){
			dp[2][i] += dp[j][i - 1];
		}
		dp[0][i] += dp[2][i - 1];
	}
	mint ans;
	for (int i = 0; i < 3; i++){
		ans += dp[i][n - 1];
	}
	cout << ans.val() << endl;
}
0