結果

問題 No.314 ケンケンパ
ユーザー miyajiro_cpp
提出日時 2016-12-09 23:43:40
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 552 bytes
コンパイル時間 867 ms
コンパイル使用メモリ 71,332 KB
実行使用メモリ 64,896 KB
最終ジャッジ日時 2024-11-28 20:17:38
合計ジャッジ時間 1,510 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16 WA * 1
権限があれば一括ダウンロードができます

ソースコード

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