結果
| 問題 |
No.314 ケンケンパ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-07-09 20:20:13 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 52 ms / 1,000 ms |
| コード長 | 432 bytes |
| コンパイル時間 | 488 ms |
| コンパイル使用メモリ | 67,644 KB |
| 実行使用メモリ | 51,584 KB |
| 最終ジャッジ日時 | 2024-10-13 09:41:03 |
| 合計ジャッジ時間 | 1,550 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include<iostream>
#include<vector>
using namespace std;
const int mod = 1e9 + 7;
int dp[1000001][3];
int N;
int dfs(int i, int k){
if(dp[i][k] != 0) return dp[i][k];
int res = 0;
if(k < 2){
res += dfs(i + 1, k + 1);
}
if(k > 0){
res += dfs(i + 1, 0);
}
return dp[i][k] = res % mod;
}
int main(){
cin >> N;
for(int i = 0; i < 3; i++){
dp[N][i] = 1;
}
int ans = dfs(0, 0);
cout << dp[0][0] << endl;
return 0;
}