TJOI 2015 Probability (generating function)

The meaning of problems

Seeking a randomly generated binary tree root (no reference node, in each case a different configuration of random) number of a desired leaf node.

Thinking

To do with generating function is a good question.

We consider setting \ (n-\) nodes, the sum of all the different configurations of the binary tree leaf nodes \ (F_n \) . First, \ (n-\) unlabeled root nodes of the binary tree type number \ (C_n \) , where \ (C_n \) represents the number of Cattleya. Then the recursive comparison clearly
\ [\ begin {align *} f_n & = \ sum_ {i = 0} ^ {n-1} f_ {i} C_ {n-1-i} + f_ {n-1-i} c_i \\ & = 2 \ sum f_iC_
{n-1-i} \ end {align *} \] special \ (f_0 = 0, F1 =. 1 \) (of recursion must consider special cases, often the first few item does not meet the recursive).

We set the number of columns \ (\ {f_n \} \ ) generating function \ (F. (X) \) , the number of columns \ (\ {C_n \} \ ) generating function \ (G (X) \) .

Observation recursive, the recursion we Cattleya number generation function derived inspiration may be \ (F (x) \) multiplied by \ (G (X) \) .
\ [\ Begin {align *} F (x) G (x) & = f_0C_0x ^ 0 + (f_0C_1 + f_1C_0) x ^ 1 + (f_0C_2 + f_1C_1 + f_2C_0) x ^ 2 + \ cdots \\ & = f_0C_0x ^ 0+ {f_2 \ over 2} x ^ 1 + {f_3 \ over 2} x ^ 2 + {f_4 \ over 2} x ^ 3 + \ cdots \\ & = {f_2x ^ 1 + f_3x ^ 2 + f_4x ^ 3 + \ cdots \ over2} \\ & = {F (x) - (f_0x ^ 0-f_1x ^ 1) \ over 2x} \\ & = {F (x) -x \ over 2x} \\ \ end {align *} \]
Solutions have
\ [F (x) = {
1 \ over 1-2xG (x)} \] and Cattleya number generation function \ (G (x) \) is equal to \ (\ displaystyle {1- ( 1-4x) ^ {1 \ over 2 } \ over 2x} \)

代入得到
\[ \begin{align*} F(x)&={x\over {\sqrt{1-4x}}}\\ &=x(1-4x)^{-{1\over 2}} \end{align*} \]
进行广义二项式展开
\[ \begin{align*} F(x)&=x\sum_{i=0}^{+\infty}{-{1\over 2}\choose i}(-4x)^i\\ &=x\sum_{i=0}^{+\infty}{(-{1\over 2})\times(-{3\over 2})\times\cdots\times(-{2i-1\over 2})\over i!}(-4x)^i\\ &=x\sum_{i=0}^{+\infty}{2^i\times1\times3\times\cdots\times(2i-1)\over i!}x^i\\ &=x\sum_{i=0}^{+\infty}{2^i\times{2i!\over 2^ii!}\over i!}x^i\\ &=x\sum_{i=0}^{+\infty}{2i!\over i! i!}x^i\\ &=\sum_{i=0}^{+\infty}{2i\choose i}x^{i+1}\\ &=\sum_{i=1}^{+\infty}{2i-2\choose i-1}x^i\\ \end{align*} \]

So we got
\ [f_n = \ begin {cases
} \ displaystyle {2n-2 \ choose n-1} & n> 0 \\ 0 & n = 0 \ end {cases} \] requirements of the subject, in fact, \ (\ DisplayStyle {F_n \ over C_n} \) , i.e., when the \ (n = 0 \) , the answer is \ (0 \) ; otherwise, the answer is \ (\ displaystyle {2n-2 \ choose n-1} \ over \ displaystyle { . 1 {\ over n-2N +. 1 {} \}} n-the Choose \) .

Simplified look into the \ (\ {n-DisplayStyle (n-+. 1) \ over 4N-2} \) , which is the final answer.

Code

Input \ (n-\) , output \ (\ displaystyle {n (n + 1) \ over 4n-2} \) on the line, the code to what? ?

Guess you like

Origin www.cnblogs.com/Paulliant/p/11670120.html