結果

問題 No.314 ケンケンパ
ユーザー 404Mao404Mao
提出日時 2017-12-30 00:32:20
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 14 ms / 1,000 ms
コード長 618 bytes
コンパイル時間 1,396 ms
コンパイル使用メモリ 144,184 KB
実行使用メモリ 15,028 KB
最終ジャッジ日時 2023-08-23 09:10:35
合計ジャッジ時間 2,290 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) FOR(i,0,n)

using ll = long long;

int dp[1000010][3];

int main(void) {
	int mod = 1e9 + 7;
	int n; cin >> n;
	REP(i, n)REP(j, 3)dp[i][j] = 0;
	dp[1][1] = 1;//ケン
	for (int i = 1; i < n; ++i) {
		(dp[i + 1][1] += dp[i][0]) %= mod;//->ケン
		(dp[i + 1][0] += dp[i][1]) %= mod;//->パー
		(dp[i + 1][2] += dp[i][1]) %= mod;//->ケンケン
		(dp[i + 1][0] += dp[i][2]) %= mod;//->パー
	}

	ll ans = 0;
	REP(i, 3) {
		(ans += dp[n][i]) %= mod;
	}
	cout << ans%mod << "\n";
	return 0;
}
0