結果

問題 No.314 ケンケンパ
ユーザー めうめう🎒
提出日時 2016-03-27 17:17:07
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 62 ms / 1,000 ms
コード長 800 bytes
コンパイル時間 713 ms
コンパイル使用メモリ 72,812 KB
実行使用メモリ 56,704 KB
最終ジャッジ日時 2024-10-02 04:57:38
合計ジャッジ時間 2,024 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

int n;
int memo[1000010][3];

int saiki(int now,int how_ken){
	if(memo[now][how_ken] != INF) return memo[now][how_ken];
	if(how_ken == 3) return 0;
	if(now == n) return 1;
	int a = 0,b = 0;
	if(how_ken <= 1) a = saiki(now + 1,how_ken + 1);	//ken
	if(how_ken != 0) b = saiki(now + 1,0);	//pa
	return memo[now][how_ken] = (a + b) % 1000000007;
}

int main() {
	for(int i = 0;i < 1000010;i++){
		for(int j = 0;j < 3;j++){
			memo[i][j] = INF;
		}
	}
	cin >> n;
	cout << saiki(0,0) % 1000000007 << endl;
	return 0;
}
0