This article is reproduced, this is the original link: Click to open the link
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 is 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 from 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-an+1].
=============================================================================================================== ===========
Example 2: If there are 1 grams, 2 grams, 3 grams, 4 grams of weight each one, can weigh what kinds of weight. There are several possible scenarios.
Constructs a parent function, if the weight is indicated by the exponent of X, then:
A 1 gram weight can be expressed as a function 1+x (the previous 1 represents a 1 gram weight of 0).
A 2 gram weight can be represented by the function 1+x2,
A 3 gram weight can be represented by the function 1+x3,
A 4 gram weight can be represented by the function 1+x4,
The product of the combination of several weights is expressed as: (1+x) (1+x2) (1+x3) (1+x4) =1+x+x2+2x3+2x4+2x5+2x6+2x7+x8+x9+x10, which is the number of schemes.
Examples of items weighing 6 are: ①, 1,2,3;②, 2, 42 options.
=============================================================================================================== ===========
Example 3:1 points, 2 points and 3 points are used to put out the number of different numerical schemes.
This is the case with the above example: this stamp can be repeated. The resulting function is: G (x) = (1+x+x2+ ...) (1+x2+x4+ ...) (1+x3+x6+ ...), and the coefficient is the number of scenarios when unfolded.
=============================================================================================================== ===========
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 means that weights A1 and objects are placed in the same pallet, xa1 that weights and objects are placed in different trays, and 1 is not used for this 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+ ...) (1+x2+x4+x6+x8+ ...) (1+x3+x6+x9+ ...) ........ (1+XN)
The front 1+x2+x4+x6+x8+ ... This means that when there is a 2 o'clock for x2, when there are two 2 o'clock for X4 ... why, when n is present, there are only two (1+XN), because the number of n is divided into several items, so the number cannot be exceeded, and the number of 1 to n is sequentially <=n/k (K=1.2,3,4...N).
or the Nyist 90 (number division) as an example: this is the direct use of online templates
[CPP] View plain copy print? #include <iostream> #include <cstring> #include <algorithm> using namespace std; const int max=50; #define &NBSP;CLR (Arr,val) memset (arr,val,sizeof (arr)) int n,m,value[max],temp[max]; Int main () { cin>>m; while (m--) { cin>>n; Fill (value,value+max,1);//value used to store coefficients clr ( temp,0)//temp used to keep each situation for (int i=2;i<=n;i + +) { for (int j=0;j<=n;j++) for (int k=0;k+j<=n;k+=i) //controls the variation of each coefficient and the maximum number of entries per number temp[k+j]+=value[j]; for (int j=0;j<=n;j++) value[j]=temp[j],temp[j]=0; } cout <<value[n]<<endl; } return 0; }
=============================================================================================================== ===========
Example 2:hdu 1085 (coin problem) [CPP] view plain copy print? There are 3 denominations of 1, 2, 5 coins, and the input of 3 numbers represents the number of pieces of each coin, and the smallest denomination that cannot be made up of these coins. #include <iostream>