Mother function Detailed explanation

Source: Internet
Author: User

The parent function is also called the generating function. The definition is given sequence: A0,A1,A2,....... ak,......, then function G (x) =a0+a1*x+a2*x2+......ak*xk called sequence A0,A1,A2,....... AK,...... The parent function (that is, the build function).

For example, the generating function for sequence 1,2,3.......N is: G (x) =x+2x2+3x3+........nxn. Click this link: Baidu Encyclopedia

Special when the sequence is: 1,1,1,1, .... 1, this generating function is: g (x) =x+x2+x3+.......+xn= (1-xn)/(1-x), when -1<x<1 G (x) =1/(1-x)

1/(1-x)n=1+c (n,1) x+c (n+1,2)x2+c (n+2,3)x3+...+c (n+k-1,k)xk+ ... You can restore the build function to an array.

=============================================================================================================== ===========

Example 1: Use the parent function to find the formula of the Fibonacci sequence. FIB (n) =fib (n-1) +fib (n-2), here assumes that the FIB (1) =1,fib (2) = 1;

The method of solving this recurrence relation is: ①, the recursive relation becomes the parent function equation, the ②, the solution of the female function equation, the ③, the female function becomes the power series form.

So the generation function of the Fibonacci sequence is: G (x) = x+x2+2x3+3x4+5x5+8x6 ....

Both sides of the equation are *x: XG (x) = x2+x3+2x4+3x5+5x6+8x7+ ....

Add: G (x) +xg (x) =x+2x2+3x3+5x4+8x5+13x6+ ...

We compare g (x) to get:g (x) +xg (x) =g (x)/x-1; So we can get:g (x) =x/(1-x-x2).

Can make: 1-x-x2=0, get two root for: a= (1-√5)/2,b= (1+√5)/2, so we can know: 1-x-x2= (x-x1) (x-x2) = (1-ax) ( 1-bx);

Assuming x/(1-x-x2) =m/(1-ax) +n/(1-BX),-Pass has: X=m (1-BX) +n (1-ax). The m=-1/√5,n=1/√5 is available by the coefficient relationship, so g (x) =-1/√5 (1-BX) +1/√5 (1-ax).

We know: 1/(1-BX) =1/[1-(1+√5)/2x] is a male ratio (1+√5)/2 geometric series, 1/(1-ax) is the male ratio (1-√5)/2 geometric series, so its general formula is: Fib (n) =1/√5[bn+1-a N+1].

=============================================================================================================== ===========

Example 2: If there are 1 grams, 2 grams, 3 grams, 4 grams of weight each one, what kinds of weight can be weighed? What are the possible options?

Constructs a parent function, if the weight is indicated by the exponent of X, then:
1 weights of 1 grams can be represented by the function 1+x, (the preceding 1 means 1 grams of weights 0)
1 2 grams of weights can be 1+x2 ,
1 3 grams of weights can be 1+x3 ,
1 4 grams of weights can be 1+x4 ,

Then the product of the combination of several weights is expressedas: (1+x) (1+x2) (1+x3) (1+x4) =1+x+x2+2x3+2x4+2x5+2x6+2x7+x8+x9+x10, the coefficient is the number of schemes .

Examples of items weighing 6 are: ①, 1,2,3;②, 2, 42 options.

=============================================================================================================== ===========

Example 3: 1 points, 2 points, 3 points of the stamps to put out the number of different numbers of programs?

This is the case with the above example: this stamp can be repeated. It is known that the generating function is : G (x) = (1+x+x2+ ...) (1+x2+x4+ ...) (1+x3+x6+ ...), the coefficient is the number of schemes after the co-rationale is expanded.

=============================================================================================================== ===========

Example 4: De Mechiriac weighing problem

(1) Weight for A1,a2,a3.....ak, how to put in the balance of the two ends, can be said to weigh n the different ways of the object is CN, then the parent function of CN is:

G (x) = (x-a1+1+xa1) (x-a2+1+xa2) ... (x-ak+1+xak)------ X-A1 said weight A1 and objects placed in the same pallet,xa1 that weights and objects placed in different trays, 1 is not the weight.

(2) Weights for A1,a2,a3....ak, such as can only be placed at one end of the balance, can be said to weigh n the different ways of the object is CN, then the parent function of CN:

G (x) = (1+xa1) (1+xa2) ... (1+Xak)

=============================================================================================================== ===========

Example 5: dividing integers into several integers (equivalent to placing n apples on n indistinguishable plates, each plate can be placed in multiple, or not), as mentioned in the previous blog post.

Assuming that 1 appears as the number of occurrences of a1,2 as the number of occurrences of A2.........K as AK, then the resulting function is:

g (x) = (1+x+x2+x3+x4+.....< Span style= "FONT-SIZE:14PX;" >) (1+x2+ x4+x6+x8+ ... 1+x3+x6+x9+ .... n )

front 1+x2+x4+x6+x8+ ... This means when a 2 o'clock appears for x2, when appears two 2 o'clock for x4. Why, when n is present, there are only two 1+xn

or the Nyist 90 (number division) as an example: this is the direct use of online templates

[CPP]View Plaincopyprint?
  1. #include <iostream>
  2. #include <cstring>
  3. #include <algorithm>
  4. Using namespace std;
  5. const int max=50;
  6. #define CLR (Arr,val) memset (arr,val,sizeof (arr))
  7. int N,m,value[max],temp[max];
  8. int main ()
  9. {cin>>m;
  10. While (m--)
  11. {cin>>n;
  12. Fill (value,value+max,1); //value used to store coefficients
  13. CLR (temp,0); //temp used to keep every situation.
  14. For (int i=2;i<=n;i++)
  15. {for (int j=0;j<=n;j++)
  16. For (int k=0;k+j<=n;k+=i) //control the change of each coefficient and the maximum number of entries per number
  17. TEMP[K+J]+=VALUE[J];
  18. For (int j=0;j<=n;j++)
  19. value[j]=temp[j],temp[j]=0;
  20. }
  21. cout<<value[n]<<endl;
  22. }
  23. return 0;
  24. }

=============================================================================================================== ===========

Example 2:hdu 1085 (coin problem)

[CPP]View Plaincopyprint?
  1. There are 3 denominations of 1, 2, 5 coins, enter 3 numbers for each coin of the number of pieces, to find the smallest can not be composed of these coins of the denomination is how much?
  2. #include <iostream>
  3. #include <cstring>
  4. #include <algorithm>
  5. Using namespace std;
  6. const int max=8010;
  7. #define CLR (Arr,val) memset (arr,val,sizeof (arr))
  8. int value[max],temp[max],num[3],coin[3]={1,2,5};
  9. int main ()
  10. {while (cin>>num[0]>>num[1]>>num[2])
  11. { if (num[0]+num[1]+num[2]==0) break ;
  12. int max=num[0]+2*num[1]+5*num[2];
  13. CLR (value,0);
  14. CLR (temp,0);
  15. Fill (value,value+num[0]+1,1);
  16. For (int i=1;i<3;i++)
  17. {for (int j=0;j<=max;j++)
  18. For (int k=0;k+j<=max&&k/coin[i]<=num[i];k+=coin[i])//Note cannot exceed the number
  19. TEMP[K+J]+=VALUE[J];
  20. For (j=0;j<=max;j++)
  21. value[j]=temp[j],temp[j]=0;
  22. }
  23. For (i=0;i<=max+1;i++)//Traversal
  24. if (value[i]==0) {cout<<i<<endl;   break;}
  25. }
  26. return 0;
  27. }

Related to the parent function of the topic are: HDU 1171,1398,1709,2065,2069,2082,2152;poj 3046,3716,3734 and so on ~ have time to do, there are a lot of things do not understand, should be first summed up the other knowledge ~ ~

Mother function Detailed explanation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.