#include "iostream"
using namespace Std;
int main ()
{
int n,i,j,k;
int c[122],temp[122];
C[] Array to store the coefficients of the current polynomial
Temp[] array is used to temporarily store the coefficients of the addition of two polynomial at the time of operation and
while (cin>>n&&n!=0)
{
for (i=0;i<122;i++) //coefficient initialization, current c[] refers to the polynomial is the first polynomial
{c[i]=1;temp[i]=0;}
for (i=2;i<=n;i++) //control of the number of operations
{
for (j=0;j<=n;j++)
for (k=0;k+j<=n;k+=i)
TEMP[K+J]+=C[J]; //Factor addition
for (j=0;j<=n;j++) //new polynomial coefficients and temp[] initialization
{
C[J]=TEMP[J];
temp[j]=0;
}
}
cout<<c[n]<<endl;
}
return 0;
}
I have seen the mother function and the code of the evening, forgive me stupid, always understand a little, so I share with you.
The source problem is the 1028 questions of the ACM, probably the idea is to find the integer n split fraction, probably the algorithm thinking there are two, one is the polynomial multiplication, one is recursion, I was at first from the recursive consideration, later found that I can not find recursion law, because it is a two-dimensional array recursion, record[n-m][m]+ Record[n][m-1] (n>m) (Excuse me for not finding his law) so I started on the polynomial.
First give the formula (which is good): G (n) = (1+x+x^2+....x^i) * (1+x^2+x^4+....x^i) (1+x^3...+x^i) ..... (1+x^i) (I refers to the nearest n and satisfies the law and is less than or equal to N)
As for the formula, their own understanding, is probably the permutation combination, this or Baidu a bit of the basic concept of the Mother function is better (baby is a mathematical slag)
For the implementation of the algorithm: we can think g1*g2*g3*g4 ... Gi, you can first calculate g1*g2, get GH, then let gh*g3, so there is a large number of cyclic control operations
The number of times for a polynomial can be expressed as an array subscript, and coefficients are expressed as array values, stored in the c[] array, and the polynomial multiplied by c[] can be used for a third cycle to represent the coefficients of the for (k=0;k+j<=n;k+=i) {},temp[i] to temporarily store the items multiplied by the number I. , K+j is the number of times that the two polynomial is multiplied by one of its respective items. After each calculation is completed, it can be transferred from temp[] to c[],temp[] 0 and then multiplied by the next polynomial.
For the polynomial proposal everyone to study well in the permutation of the combination and some of the more troublesome issues of considerable importance, Taylor formula did not learn, baby heart bitter! Math is important, really! For mathematical problems such as polynomial and parent functions, I have made up the gap to share with you.
hdu,1028, understanding of integer splitting