Cattleya number, also known as catalain number, English name Catalan numbers, is a combinatorial mathematics often appear in various counting problems appear in the series. Named by the Belgian mathematician Eugen Charlie Katalan (1814–1894), the first items are: 1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796, 58786, 208012, 742900, 2674440, 969 4845, 35357670, 129644790, 477638700, 1767263190, 6564120420, 24466267020, 91482563640, 343059613650, 1289904147324, 4861946401452, ...--from Baidu Encyclopedia
This is not the first time I have touched the number of Cattleya, these seemingly irregular numbers actually have origins.
Here the formula is attached
Make the H (0) =1,h (1) =1,catalan number meet the recursion:
H (N) = h (0) *h (n-1) +h (1) *h (n-2) + ... + h (n-1) H (0) (n>=2)
Alternative recursion Type:
H (N) =h (n-1) * (4*n-2)/(n+1);
The solution of a recursive relationship is:
H (N) =c (2n,n)/(n+1) (n=0,1,2,...)
The alternative solution to the recursive relationship is:
H (N) =c (2n,n)-C (2n,n-1) (n=0,1,2,...)
About the application of Cattleya, the most general is to calculate the probability of stacking order, of course, it has a lot of deformation, there is a blog post written in more detail--http://blog.csdn.net/duanruibupt/article/details/6869431
Finally, it's just a question from the AC recently, right when it's an example.
===========================================================================================================
Gorgeous split Line
===========================================================================================================
Title Description
Description
Competition class of the younger brothers are very lazy, everyone does not like to take out the garbage, the result will be the same as the senior RP of the more heap, of course, teachers will occasionally ask them to take out the garbage. Because they are really lazy, they only take the top bag of the trash can and throw it directly. When the younger brothers throw rubbish, they will put the rubbish into bags first, then the garbage number, the first bag throws to the rubbish bin rubbish to make the ① number ... Dig the garbage Aberian order, and then feedback to the teacher, let the teacher know how lazy the competition class in the end ... "For example: when the younger brothers throw 3 bags of rubbish, the number can be 123 (each bag thrown into the dustbin when they take to throw, this number indicates that some people are very industrious), 132 (first bag take out and throw, then the garbage can throw more than the 2nd, 3 bags, they again from a bag of bags to throw away) ... "and the competition class A brother to the arbor admiration has been long, want to know how many of the last received the order of garbage, because he did not study science and culture Knowledge, iq a little catch chicken, So I want you to help him figure out, but you feel that the practice is stupid enough to explode, so you decided to let the computer to do this thing.
If the computer in the 1s does not work out, the teenager, take out the garbage, you are too lazy ...
Enter a description
Input Description
There is only an integer n, which indicates how many bags of rubbish the younger brothers threw.
Output description
Output Description
There is only one integer m, which indicates the total possible result of the order of the arbor taking out the rubbish.
Sample input
Sample Input
3
Sample output
Sample Output
5
Data range and Tips
Data Size & Hint
Time limit
1s per test point
Data range
For 50% of data, 1≤n≤15
For 100% of data, 1≤n≤35
Hint
Rubbish to fall on time, have not heard of the man who trash the most sexy? "Where does this remark = =" ...
35 Bags of garbage ... Yao always told you not to eat in the computer room to hear.
Thinking of solving problems
At first, I was lazy, using the formula H (n) =h (n-1) (n*4-2)/(n+1), but there was a point but
Then I honestly knocked on the first formula, and it was over. What is this for? Because the second formula involves multiplication, it is possible to explode (what?) by first multiplying. Do you mean to use a real edge to remove the edge? Accuracy not enough)
So, the second formula applies only to N<=34
The second formula applies only to N<=34
The second formula applies only to N<=34
(important thing to say three times)
1 Programtt;2 varH:Array[0.. *] ofQword;3 N,i,j:longint;4 begin5 read (n);6h[0]:=1;7h[1]:=1;8 fori:=2 toN Do9 forj:=0 toI-1 DoTenh[i]:=h[i]+h[j]*h[i-j-1]; One Writeln (H[n]); A End.
Number of Cattleya