HDU 1028 Ignatius and the Princess III(母函数整数拆分)

链接:传送门
题意:一个数n有多少种拆分方法
思路:典型母函数在整数拆分上的应用

/*************************************************************************
> File Name: 1.cpp
> Author: WArobot
> Blog: http://www.cnblogs.com/WArobot/
> Created Time: 2017年04月20日 星期四 21时07分09秒
************************************************************************/

include<bits/stdc++.h>

using namespace std;

int p[130] , a[130] , b[130];
int n;

void init(){
for(int N = 1;N<=120;N++){
for(int i=0;i<=N;i++) a[i] = 1 , b[i] = 0;
for(int i=2;i<=N;i++){
for(int j=0;j<=N;j++)
for(int k=0;ki+j<=N;k++) b[ki+j] += a[j];
for(int j=0;j<=N;j++) a[j] = b[j] , b[j] = 0;
}
}
}
int main(){
init();
while(scanf("%d",&n)!=EOF && n){
printf("%d\n",a[n]);
}
return 0;
}

posted @ 2017-04-22 20:11  ojnQ  阅读(153)  评论(0)    收藏  举报