Cattleya number is a common and important special counting formula in combinatorial mathematics.
First, give a realistic model of the problem:
The number of edges of convex polygon is given, and the method to divide the area into triangular area is solved by solving the disjoint diagonal line of the convex polygon.
First we conduct a preliminary analysis, when N=2,h2=1, that is, for triangles, the number of cases divided is 1. This seems a bit difficult to understand, because the triangle inside cannot add diagonal, so the case is the triangle itself, the number of cases is 1.
Let's discuss the case where n takes any value.
Look at the picture below.
Consider the n+1 convex edge of the sub-problem, that is, we think of AB as the base edge, the position of the enumeration C, there are n-1 enumerable position, and then combined with the basic counting principle, we can see that the following recursion can not be heavy without leakage of the expression h[n].
And now the problem is that this recursive formula is what we do not like, we prefer the form of Fibonacci sequence, given the relationship between the front and back and then we can find the linear time complexity of the sequence, then we need to discuss how to get this recursive formula solution.
Here is the Java code that calculates the Cattleya sequence based on this conclusion:
ImportJava.io.*;ImportJava.util.*;ImportJava.math.BigInteger; Public classmain{ Public Static voidMain (String args[]) {biginteger[] a=NewBiginteger[101]; a[0] =Biginteger.zero; a[1] = biginteger.valueof (1); for(inti = 2; I <= 100; ++i) a[i]= A[i-1].multiply (biginteger.valueof (4 * i-2)). Divide (Biginteger.valueof (i+1)); Scanner in=NewScanner (system.in); intN; while(In.hasnext ()) {n=In.nextint (); System.out.println (A[n]); } }}
Combinatorial mathematics and its application--Cattleya number