forked from daiwb/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path191.cpp
More file actions
41 lines (29 loc) · 670 Bytes
/
191.cpp
File metadata and controls
41 lines (29 loc) · 670 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include <sstream>
#include <algorithm>
#include <iterator>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
using namespace std;
typedef long long LL;
#define MAXN 30
LL mm[MAXN + 1][2][2][2];
LL dp(int left, int late, int a, int b) {
LL& ret = mm[left][late][a][b];
if (ret != -1) return ret;
if (left == 0) return ret = 1;
ret = 0;
if (late == 0) ret += dp(left - 1, 1, b, 0);
if (a + b <= 1) ret += dp(left - 1, late, b, 1);
ret += dp(left - 1, late, b, 0);
return ret;
}
void run() {
memset(mm, -1, sizeof(mm));
cout << dp(MAXN, 0, 0, 0) << endl;
}
int main() {
run();
}