标签:des style blog http java color
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7883 Accepted Submission(s): 5332
母函数入门题
1 //0MS 200K 615 B G++ 2 #include<stdio.h> 3 #define N 305 4 int c1[N],c2[N]; 5 int _n[18]={1,4,9,16,25,36,49,64,81,100,121,144,169,196,225,256,289}; 6 int fun(int n) 7 { 8 int i,j,k; 9 for(i=0;i<=n;i++){ 10 c1[i]=1; 11 c2[i]=0; 12 } 13 for(i=1;i<17;i++){ 14 for(j=0;j<=n;j++) 15 for(k=0;k+j<=n;k+=_n[i]) 16 c2[j+k]+=c1[j]; 17 for(j=0;j<=n;j++){ 18 c1[j]=c2[j]; 19 c2[j]=0; 20 } 21 } 22 return c1[n]; 23 } 24 int main(void) 25 { 26 int n; 27 while(scanf("%d",&n)!=EOF) 28 { 29 if(n==0) break; 30 printf("%d\n",fun(n)); 31 } 32 return 0; 33 }
hdu 1398 Square Coins (母函数),布布扣,bubuko.com
标签:des style blog http java color
原文地址:http://www.cnblogs.com/GO-NO-1/p/3819730.html