結果

問題 No.314 ケンケンパ
ユーザー zoom4638zoom4638
提出日時 2015-12-11 17:34:02
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 798 bytes
コンパイル時間 757 ms
コンパイル使用メモリ 52,220 KB
実行使用メモリ 10,468 KB
最終ジャッジ日時 2023-10-13 10:57:23
合計ジャッジ時間 2,335 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,356 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 2 ms
4,356 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 2 ms
4,352 KB
testcase_12 AC 2 ms
4,352 KB
testcase_13 AC 2 ms
4,356 KB
testcase_14 AC 3 ms
4,348 KB
testcase_15 AC 3 ms
4,352 KB
testcase_16 AC 4 ms
5,216 KB
testcase_17 AC 12 ms
10,468 KB
testcase_18 RE -
testcase_19 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

long long int dp[100003][3][3];

int main() {
	int n;
	cin >> n;
	dp[1][1][0] = 1;
	
	for (int i = 2; i <= n; i++){
		for (int j = 0; j < 3; j++){
			for (int k = 0; k < 3; k++){
				if (dp[i - 1][j][k] != 0){
					if (j == 1 && k == 1){
						dp[i][2][j] += dp[i - 1][j][k];
						dp[i][2][j] %= 1000000007;
					}else{
						if (j == 2){
							dp[i][1][j] += dp[i - 1][j][k];
							dp[i][1][j] %= 1000000007;
						}else{
							for (int l = 1; l < 3; l++){
								dp[i][l][j] += dp[i - 1][j][k];
								dp[i][l][j] %= 1000000007;
							}
						}
					}
				}
			}
		}
	}
	
	long long int ans = 0;
	
	for (int i = 1; i < 3; i++){
		for (int j = 1; j < 3; j++){
			ans += dp[n][i][j];
			ans %= 1000000007;
		}
	}
	
	cout << ans << endl;
	return 0;
}
0