結果
問題 | No.314 ケンケンパ |
ユーザー |
![]() |
提出日時 | 2016-07-20 20:19:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 137 ms / 1,000 ms |
コード長 | 782 bytes |
コンパイル時間 | 915 ms |
コンパイル使用メモリ | 100,968 KB |
実行使用メモリ | 104,772 KB |
最終ジャッジ日時 | 2024-11-14 19:46:56 |
合計ジャッジ時間 | 2,206 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <iostream>#include <sstream>#include <string>#include <vector>#include <functional>#include <tuple>#include <climits>#include <algorithm>#include <queue>#include <unordered_map>#include <unordered_set>#include <set>#include <iomanip>using namespace std;int N;vector<vector<int>> dp;uint64_t solve(int index, int ken){if(ken>=3)return 0;if(index==N)return 1;if(dp[index][ken] != -1)return dp[index][ken];uint64_t a=0, b=0;if(ken!=0)a = solve(index+1, 0); // パb = solve(index+1, ken+1);dp[index][ken] = (a+b)%(1000000000+7);return dp[index][ken];}int main(){cin >> N;dp.resize(N);for(auto &a : dp)a.resize(3,-1);cout << solve(0, 0) << endl;}