結果

問題 No.314 ケンケンパ
ユーザー miyajiro_cppmiyajiro_cpp
提出日時 2016-12-09 23:43:40
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 552 bytes
コンパイル時間 654 ms
コンパイル使用メモリ 71,592 KB
実行使用メモリ 65,024 KB
最終ジャッジ日時 2024-05-06 13:28:13
合計ジャッジ時間 1,528 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
65,024 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 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 1 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 8 ms
9,856 KB
testcase_18 AC 32 ms
33,536 KB
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;
const ll mod=1e9+7;
ll n;
ll dp[1000000][3];
ll rec(ll n,ll k){//k 0:pa  1:ken1 2:ken2 3:ken3
	if(dp[n][k]) return dp[n][k];
	if(n==0) return 1;
	ll res=0;
	if(k>0) res+=rec(n-1,0);
	if(k<2) res+=rec(n-1,k+1);
	return dp[n][k]=res%mod;
}

int main()
{
	cin>>n;
	printf("%lld\n",rec(n,0));
}
0