hdu1028 母函数

 1 #include<stdio.h>
 2 #include<math.h>
 3 int main()
 4 {
 5     int i,j,k,n,m,c1[10005],c2[10005];
 6     while (~scanf("%d",&n))
 7     {
 8           for (i=0;i<=n;i++) {c1[i]=1; c2[i]=0; }
 9           for (i=2;i<=n;i++)
10           {
11             for (j=0;j<=n;j++)
12              for (k=0;k<=n-j;k+=i) c2[j+k]+=c1[j];
13             for (j=0;j<=n;j++)
14              {c1[j]=c2[j]; c2[j]=0; }
15           }
16           printf("%d\n",c1[n]); 
17     }
18     return(0);
19 }

posted on 2014-07-16 16:25  xiao_xin  阅读(89)  评论(0编辑  收藏  举报

导航