結果

問題 No.314 ケンケンパ
ユーザー srup٩(๑`н´๑)۶
提出日時 2016-08-29 20:57:52
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 789 bytes
コンパイル時間 610 ms
コンパイル使用メモリ 59,396 KB
実行使用メモリ 26,976 KB
最終ジャッジ日時 2024-11-14 06:48:31
合計ジャッジ時間 1,541 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 7 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
const int mod = 1e9 + 7;
//dp[i][j] := i番目まで考えて、
ll dp[1000010][3];
int main(void){
	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){
		for (int j = 0; j < 3; ++j){
			if(j == 0){//*パー
				(dp[i + 1][1] += dp[i][0]) %= mod;//ケン
			}else if(j == 1){//*パー ケン
				(dp[i + 1][0] += dp[i][1]) %= mod;//パー
				(dp[i + 1][2] += dp[i][1]) %= mod;//ケン
			}else if(j == 2){//*パー ケン ケン
				(dp[i + 1][0] += dp[i][2]) %= mod;//パー
			}
		}
	}

	ll ans = 0;
	rep(i, 3){
		ans += dp[n][i];
	}
	printf("%lld\n", ans);
	return 0;
}
0