結果
| 問題 | No.314 ケンケンパ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-02-08 21:45:43 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 863 bytes |
| 記録 | |
| コンパイル時間 | 1,294 ms |
| コンパイル使用メモリ | 157,936 KB |
| 実行使用メモリ | 9,984 KB |
| 最終ジャッジ日時 | 2024-09-21 21:50:21 |
| 合計ジャッジ時間 | 2,078 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 WA * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(i=0;i<n;++i)
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
const long mod=1e9+7;
long n;
//今x歩まで進んできて、ケンがy回連続している
long dp[100001][3];
long rec(long x, long y){
if(dp[x][y]>=0) return dp[x][y];
long ret=0;
if(x==n) ret=1;
else{
if(y==0){//ケンしか置けない
ret=rec(x+1,y+1);
}
else if(y==1){//両方おける
ret=rec(x+1,y+1)+rec(x+1,0);
}
else if(y==2){//パしか置けない
ret=rec(x+1,0);
}
}
return dp[x][y]=ret%mod;
}
int main(int argc, char const *argv[]) {
cin >>n;
memset(dp,-1,sizeof(dp));
std::cout << rec(0,0) << std::endl;
return 0;
}