[Turn] Parent function

Source: Internet
Author: User

Reprinted from: http://blog.csdn.net/lishuhuakai/article/details/8044431

Explanation of the parent function (generating functions)

In mathematics, the parent function of a sequence is a form power series whose coefficients can provide information about the sequence. The method of solving a problem by using a parent function is called a parent function method .

The female function can be divided into many kinds, including common parent function , exponential parent function,L series , Bell series and Dirichlet series . For each sequence, you can write a parent function for each of these types. The purpose of constructing a parent function is generally to solve a particular problem, so the choice of which parent function depends on the nature of the sequence itself and the type of problem.

Here first give two words, do not understand can wait to read this article and then back to see:

"The addition of combinatorial problems corresponds to the sum of the power of T of a power series".

"The idea of the mother function is simple--that is, the discrete series and the power series one by one corresponding to the discrete sequence of the inter-binding relationship between the power series is the operational relationship, and finally from the form of power series to determine the structure of discrete series."

Let's look at this polynomial multiplication first:

From this we can see:

1. The coefficient of x is a1,a2,... an individual combination of the whole.

2. The coefficient of X2 is the A1,A2,... an of two combinations of the whole.

.........

N. The coefficient of Xn is the total of n combinations of A1,a2,.... an (only 1).

This leads to:

Definition of the parent function:

For sequence a0,a1,a2, ... Construct a function:

Called function g (x) is a sequence of a0,a1,a2, ... The parent function

Here first give 2 examples, and so on will be combined with the topic analysis:

The first type:

1 grams, 2 grams, 3 grams, 4 grams of weight each one, can weigh what kinds of weight? How many possible options are available for each weight?

Consider the problem of kissing with a parent function:

We assume that x represents weights, and the exponent of x represents the weight of weights, so:

A 1 gram weight can be represented by the function 1+x,

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,

These four formulas above, you know?

For 1+X2, we have said earlier that X is a weight, and the exponent of x is the weights, that is, this is a mass of 2, so what does the preceding 1 mean? 1 represents a weight of 2 weights of 0. Understand )

Do not know that everyone understands not, we here combine the preceding sentence:

"The addition of combinatorial problems corresponds to the sum of the power of T of a power series".

1+X2 represents two cases: 1 for weight of 2 for 0, X2 for weight of 2 for 1.

Here are the meanings of the coefficients:

In the x front of the coefficient A is the weight of the corresponding quality to take a, and 1 means that the corresponding weight to take 0, here can not simply consider the corresponding weight 0 should be 0*x2 (think of why? Combined with mathematical formulas).

So, what is the meaning of the sentence that we have said before can you understand?

The combination of several weights can be weighed, and can be represented by the product of several of these functions:

(1+x) (1+X2) (1+X3) (1+x4)

= (1+x+x2+x3) (1+x3+x4+x7)

=1+x+x2+2x3+2x4+2x5+2x6+2x7+x8+x9+x10

From the above function know: can be weighed from 1 grams to 10 grams, the coefficient is the number of schemes. (!!! Classic!!! )

For example, there are 2x5 on the right end , that is, the scheme of 5 grams is 2:5=3+2=4+1; 6=1+2+3=4+2;10=1+2+3+4.

It is said that 6 grams of the scheme has 2, said 10 grams of the scheme has 1.

Next up, here's the second case:

1, 2, and 3 stamps are used to post different numbers of programs:

What is the difference between this situation and the first comparison? The first of each is one , and each of these is infinite .

Take the expanded X4 as an example, its coefficient is 4, that is 4 split into 1, 2, 3 and the split fraction of 4;

namely: 4=1+1+1+1=1+1+2=1+3=2+2

This leads to two conceptual integer splits and split fractions:

The so-called integer splitting is the sum of the integers divided into integers (equivalent to the N-no-difference ball in the N unmarked box, the box is allowed to be empty, and more than one ball can be placed).

Integers are divided into several integers, with different methods, and the total number of split methods is called split fractions .

Now in the second case above, for example, the number of each species is infinite, the template is given:

#include <iostream>usingnamespace std; constint _max=10001;//C1 is the number of weights that can be combined to preserve each weight//C2 is the middle volume, save the situation onceIntc1[_max], C2[_max]; Intmain () {//int n,i,j,k;    intNnum;//    intI, j, K;  while(Cin >>nnum) {        for(i=0; i<=nnum; ++i)//----①{C1[i]=1; C2[i]=0; }        for(i=2; i<=nnum; ++i)//-----②       {             for(j=0; j<=nnum; ++J)//-----③               for(k=0; k+j<=nnum; K+=i)//----④{c2[j+k] + =C1[j]; }            for(j=0; j<=nnum; ++J)//----⑤{C1[j]=C2[j]; C2[J]=0; }} cout<< C1[nnum] <<Endl; }    return 0;} 

Let's explain the various places on the above signs:

①, first initializes the C1 by the first expression (1+x+x2+. xn) is initialized to initialize all weights from 0 to N of the mass to 1.

②, I from 2 to n traversal, here I refers to the first expression, the second type of parent function, given above, each parenthesis is an expression.

③, J is traversed from 0 to N, where J is only the first J variable in an expression, such as in the second expression: (1+x2+x4 ...) , the first J is x2*j.

③k represents the J index, so k increments I each time (because the increment of the I-expression is i).

④, assign the value of C2 to C1, and initialize C2 to 0, because C2 starts each time from an expression

Let's hurry up and strike a few questions:

(the corresponding problem analysis is analyzed in the corresponding code)

1. Title: http://acm.hdu.edu.cn/showproblem.php?pid=1028

Let's look at the simple question. The above template is understood, this problem is small case!

Look at this question:

2. Title: http://acm.hdu.edu.cn/showproblem.php?pid=1085

To say the difference from the previous question, we only need to change 2 places. When I traverse the expression (can refer to my data---"description of the parent function"), the i<=nnum changed to I*i<=nnum, and then the K-Traversal index k+=i into the k+=i*i; Ok, it's still a set of templates ~ ~ ~

3. Title: http://acm.hdu.edu.cn/showproblem.php?pid=1398

The problem finally changed a little, but the change is not one of them.

The analysis, the combination of code will understand.

4. Title: http://acm.hdu.edu.cn/showproblem.php?pid=2079

5. Title: http://acm.hdu.edu.cn/showproblem.php?pid=2082

See the 5 code above: http://www.cnblogs.com/hate13/p/4165146.html

There are some questions that you have time to do yourself:

hdoj:1709, 2069, 2152

Report:

1. In Wikipedia, you'll talk about common parent functions, number of letters, L class, the number of grades, and Dirichlet:

Http://zh.wikipedia.org/zh-tw/%E6%AF%8D%E5%87%BD%E6%95%B0

2. Matrix67 Daniel There is an article: what is a build function:

http://www.matrix67.com/blog/archives/120

3. You can take a look at Hang Electric's ACM courseware, the parent function of the article, my picture here and some of the content is led to that.

[Turn] Parent function

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.