# hdoj 1028 Ignatius and the Princess III

dp(p, n) = n的整数划分方案数其中规定最大的整数不大于p

dp(p, n) = (1) dp(n, n) n < p

(2) dp(p - 1, n) + dp(p, n - p) n >= p

#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define FOR(i,a,b) for(i = (a); i < (b); ++i)
#define FORE(i,a,b) for(i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(i = (a); i > (b); --i)
#define FORDE(i,a,b) for(i = (a); i >= (b); --i)
#define CLR(a,b) memset(a,b,sizeof(a))
#define PB(x) push_back(x)

const int MAXN = 122;
const int MAXM = 0;
const int hash_size = 25000002;
const int INF = 0x7f7f7f7f;

int dp[MAXN][MAXN];

int main() {
int i, j, n;
while(cin>>n) {
CLR(dp, 0);
dp[0][0] = 1;
FORE(i, 0, n)
dp[1][i] = 1;
FORE(i, 2, n)
FORE(j, 0, n)
if(j < i)
dp[i][j] = dp[i - 1][j];
else
dp[i][j] = dp[i][j - i] + dp[i - 1][j];
cout<<dp[n][n]<<endl;
}
return 0;
}

06-30 1006

08-08 521

07-30 924

08-14 284

11-01 550

08-31 571

10-05 3773

07-18 911

08-06 566

12-07 1301