forked from daiwb/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path115.cpp
More file actions
47 lines (37 loc) · 738 Bytes
/
115.cpp
File metadata and controls
47 lines (37 loc) · 738 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
42
43
44
45
46
47
#include <iostream>
#include <sstream>
#include <algorithm>
#include <iterator>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
typedef long long LL;
#define MILLION 1000000
#define MAXN 1000
#define START 50
LL mm[MAXN + 1];
LL dp(int n) {
LL& ret = mm[n];
if (ret != -1) return ret;
if (n == 0) return ret = 1;
ret = dp(n - 1);
if (n >= START) ++ret;
FOR(i,START,n-1) ret += dp(n - i - 1);
return ret;
}
void run() {
memset(mm, -1, sizeof(mm));
FOR(i,3,MAXN) {
LL t = dp(i);
if (t >= MILLION) {
cout << i << endl;
break;
}
}
}
int main() {
run();
}