結果
| 問題 |
No.314 ケンケンパ
|
| コンテスト | |
| ユーザー |
miyajiro_cpp
|
| 提出日時 | 2016-12-09 23:44:52 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 73 ms / 1,000 ms |
| コード長 | 552 bytes |
| コンパイル時間 | 684 ms |
| コンパイル使用メモリ | 71,736 KB |
| 実行使用メモリ | 66,048 KB |
| 最終ジャッジ日時 | 2024-11-28 20:18:59 |
| 合計ジャッジ時間 | 1,662 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#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));
}
miyajiro_cpp