代码:
#include<cstdio> #include<cmath> using namespace std; int main() { int n; int c1[150],c2[150]; while(scanf("%d",&n)==1) { for(int i=0;i<=n;i++) { c1[i]=1; c2[i]=0; } for(int i=2;i<=n;i++) { for(int j=0;j<=n;j++) { for(int k=0;k+j<=n;k+=i) { c2[j+k]+=c1[j]; //c1[k+j]=c2[k+j]; } } for(int j=0;j<=n;j++) { c1[j]=c2[j]; c2[j]=0; } } printf("%d\n",c1[n]); } return 0; }
hdu 1028 Ignatius and the Princess III(用母函数解决整数分拆问题)
原文:http://blog.csdn.net/xky1306102chenhong/article/details/46338133