【文件属性】:
文件名称:母函数的相关操作不懂的兄弟可以来看看很好的
文件大小:1KB
文件格式:CPP
更新时间:2013-01-02 06:36:02
母函数
#include
const int maxn = 301;
int c1[maxn], c2[maxn];
int main()
{
freopen("file.in", "r", stdin);
int elem[17] = {1,4,9,16,25,36,49,64,81,100,121,144,169,196,225,256,289};
int i, j, k, n;
while (scanf("%d", &n) && n) {
for (i = 0; i <= n; i++)
c1[i] = 1, c2[i] = 0;
for (i = 2; i <= 17; i++) {
for (j = 0; j <= n; j++) {
for (k = 0; k + j <= n; k += elem[i-1])
c2[j+k] += c1[j];
} // for_j
for (j = 0; j <= n; j++) {
c1[j] = c2[j]; c2[j] = 0;
} // for_j
} // for)i
printf("%d\n", c1[n]);
} // while
return 0;
}