-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpartitions.cpp
41 lines (33 loc) · 902 Bytes
/
partitions.cpp
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
#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <cstdio>
#include <cstring>
#include <cassert>
using namespace std;
#define FOR(i, n) for(int i=0;i<int(n);i++)
#define FOR1(i, n) for(int i=1;i<=int(n);i++)
#define FORA(i, a, n) for(int i=a;i<int(n);i++)
#define FORR(i, n) for(int i=n-1;i>=0;i--)
#define FORE(it, c) for(typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define ALL(c) c.begin(), c.end()
#define CLR(c,v) memset(c,v,sizeof(c))
typedef long long int lli;
typedef pair<int,int> ii;
const int N = 55;
int DP[N][N]; // n,x = # of partitions of n ending with x
int main()
{
ios::sync_with_stdio(false);
int n = 50;
DP[0][0] = 1;
FOR1(i,n) FOR1(j,i) DP[i][j] = DP[i][j-1] + DP[i-j][min(i-j,j)];
cout << DP[n][n] << endl;
return 0;
}