generating function

//We need to put a form like G(x)=(1+X^1+X^2+X^3+…)(1+X^2+X^4+X^6+…)….This way The function
// transform into shape like F(x)=1+X+X^2 +2*X^3 +2*X^4+2*X^5+2*X^6+2*X^7+ Function of X^8+X^9+X^10/
#include
#include
#include
using namespace std;
const int max1=10001;
//There are two arrays c1 indicating that c2 is an intermediate temporary array mother function (1+ x^1+x^2+…+x^n)(1+x^2+x^4+x^6).. (The root means that, for example, the first bracket is 1 and the second is 2 Indicates that the root is the first increase) The index/root is represented by
int c1[max1], c2[max1];
int main()
{
int n; //represents the number
while(~scanf(“%d ",&n))
{
for(int i=0;i<=n;i++){
c1[i]=1; //Indicates that the coefficients of x^i are initialized to 1, which is actually each x^ represented i will have a situation where only x^1 becomes
c2[i]=0;
}
for(int i=2;i<=n;i++)//multiply the second bracket of G(x) into F( c1[i] in x) is equivalent to the coefficient of x^i in f[x]
{
for(int j=0;j<=n;j++)//Indicates that the coefficient of the corresponding x^i in fx is multiplied by the second bracket
{
for(int k=0;k+j< =n;k+=i){ //Because it is equivalent to adding
c2[j+k]+=c1[j] with i as the root every time ;//The first item in F(x) and The exponent becomes k+j after multiplying each term of the second parenthesis in G(x) and imagining it.
}
}
for(int j=0;j<=n;j++)
{
c1[j]=c2 [j];
c2[j]=0;
}
}
printf(“%d\n”,c1[n]);//Indicates how many cases can form n
}
return 0;
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325529921&siteId=291194637