結果

問題 No.314 ケンケンパ
ユーザー miyajiro_cppmiyajiro_cpp
提出日時 2016-12-09 23:44:52
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 84 ms / 1,000 ms
コード長 552 bytes
コンパイル時間 3,184 ms
コンパイル使用メモリ 70,688 KB
実行使用メモリ 73,772 KB
最終ジャッジ日時 2023-08-19 06:19:46
合計ジャッジ時間 2,221 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
72,652 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,384 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 4 ms
5,264 KB
testcase_17 AC 11 ms
10,524 KB
testcase_18 AC 41 ms
37,384 KB
testcase_19 AC 84 ms
73,772 KB
権限があれば一括ダウンロードができます

ソースコード

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[1000001][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