結果

問題 No.314 ケンケンパ
ユーザー めうめう🎒めうめう🎒
提出日時 2016-03-27 17:17:07
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 51 ms / 1,000 ms
コード長 800 bytes
コンパイル時間 647 ms
コンパイル使用メモリ 72,728 KB
実行使用メモリ 56,596 KB
最終ジャッジ日時 2024-04-10 03:32:26
合計ジャッジ時間 1,959 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
55,968 KB
testcase_01 AC 6 ms
15,144 KB
testcase_02 AC 6 ms
15,064 KB
testcase_03 AC 6 ms
15,088 KB
testcase_04 AC 7 ms
15,176 KB
testcase_05 AC 6 ms
15,124 KB
testcase_06 AC 6 ms
14,912 KB
testcase_07 AC 7 ms
14,976 KB
testcase_08 AC 6 ms
15,068 KB
testcase_09 AC 6 ms
15,020 KB
testcase_10 AC 6 ms
15,212 KB
testcase_11 AC 6 ms
15,040 KB
testcase_12 AC 6 ms
15,036 KB
testcase_13 AC 6 ms
15,020 KB
testcase_14 AC 7 ms
15,308 KB
testcase_15 AC 7 ms
15,416 KB
testcase_16 AC 8 ms
16,124 KB
testcase_17 AC 11 ms
19,284 KB
testcase_18 AC 29 ms
35,032 KB
testcase_19 AC 51 ms
56,596 KB
権限があれば一括ダウンロードができます

ソースコード

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