This title is directly a template title of a mother function.
code show as below:
#include<iostream> #include<cstdio> #include<string.h> #include<cmath> #include<stdlib.h> #include<fstream> using namespace std; #define MAX 301 int n, cnt [500], dic [500]; int main(){ int i,j,k; while((cin>>n)&&n>0) { for( i = 0 ; i<=MAX;i++) { cnt[i]=1; } //The data represented by 1 can be infinite memset(dic,0,sizeof(dic)); // add from the second for(i=2;i<=17 ; i++) { for(j = 0 ; j <=n ; j++)//traverse all terms of the previous expression { for(k = 0 ; k+j<=n ; k+=i*i)//traverse all the current expressions { dic[j+k]+=cnt[j];//The current coefficient depends entirely on the previous coefficient, which is the coefficient of the previous formula } } for(j =0 ; j<= n ;j++) { cnt[j]=dic[j];//Transfer the temporarily stored coefficients dic[j]=0; } } printf("%d\n",cnt[n]); } }