結果

問題 No.314 ケンケンパ
ユーザー keikei
提出日時 2016-08-31 16:27:51
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 27 ms / 1,000 ms
コード長 486 bytes
コンパイル時間 454 ms
コンパイル使用メモリ 54,232 KB
実行使用メモリ 26,624 KB
最終ジャッジ日時 2024-04-26 21:38:20
合計ジャッジ時間 1,335 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
using namespace std;

/* dp[i][j]  j = 0 : ケン j = 1 : ケンケン j = 2 : パ*/
long long dp[1000000][3];
long long mod = 1000000007;

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int N; cin >> N;
	dp[1][0] = 1; dp[1][1] = 0; dp[1][2] = 0;
	for (int i = 2; i <= N; i++) {
		dp[i][0] = dp[i - 1][2];
		dp[i][1] = dp[i - 1][0];
		dp[i][2] = (dp[i - 1][0] + dp[i - 1][1])%mod;
	}
	cout << (dp[N][0] + dp[N][1] + dp[N][2]) % mod << endl;
	return 0;
}
0