标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 9903 Accepted Submission(s): 6789
#include<queue> #include<math.h> #include<stdio.h> #include<string.h> #include<string> #include<iostream> #include<algorithm> using namespace std; #define N 333 int a[22],n,d[N][N]; int main() { for(int i=1;i<=17;i++) a[i]=i*i; for(int i=0;i<=300;i++) for(int j=0;j<=300;j++) d[i][j]=1; for(int i=2;i<=300;i++) { for(int j=2;j<=17&&a[j]<=i;j++) { d[i][a[j]]=d[i][a[j-1]]+d[i-a[j]][min(a[j],i-a[j])]; d[i][i]=d[i][a[j]]; } } int i; while(cin>>i&&i) { cout<<d[i][a[(int)sqrt(i)] ]<<endl; } return 0; }
标签:
原文地址:http://www.cnblogs.com/wmxl/p/4783020.html