杭电1389 Square Coins 皇星客栈

http://acm.hdu.edu.cn/showproblem.php?pid=1398

第二个母函数直接编译无错误,但是提交时少写一个以输入0退出,哎!!!!!!

View Code
 1 #include<stdio.h>
 2 
 3 #define max 100001
 4 
 5 int main( )
 6 {
 7     int i;
 8     int j;
 9     int k;
10     int c1[max];
11     int c2[max];
12     int n;
13     while( scanf("%d",&n) == 1 )
14     {
15         
16         if( n == 0 )
17             break;
18 
19         for( i = 0; i <= n; i++ )
20         {
21             c1[i] = 1;
22             c2[i] = 0;
23         }
24 
25         for( i = 2; i*i <= n; i++ )
26         {
27 
28             for( j = 0; j <= n; j++ )
29             {
30                 for( k = 0; j+k <= n; k += i*i )
31                 {
32                     c2[j+k] += c1[j];
33                 }
34             }
35 
36             for( j = 0; j <= n; j++ )
37             {
38                 c1[j] = c2[j];
39                 c2[j] = 0;
40             }
41         }
42         
43         printf("%d\n", c1[n]);
44     }
45     return 0;
46 }
47         
原文地址:https://www.cnblogs.com/huangxingkezhan/p/2633070.html