标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 9926 Accepted Submission(s): 6806
#include<stdio.h> #include<math.h> const int MAXN=310; int main(){ int N,a[MAXN],b[MAXN]; while(~scanf("%d",&N),N){ for(int i=0;i<=N;i++) a[i]=1,b[i]=0; for(int i=2;i<=17;i++){//最大硬币值是289 for(int j=0;j<=N;j++) for(int k=0;k+j<=N;k+=i*i) b[j+k]+=a[j]; for(int j=0;j<=N;j++) a[j]=b[j],b[j]=0; } printf("%d\n",a[N]); } return 0; }
标签:
原文地址:http://www.cnblogs.com/handsomecui/p/4823084.html