The first few catlands: C0 = 1, while
C1 = 1, C2 = 2, C3 = 5, C4 = 14, C5 = 42,
C6 = 132, C7 = 429, C8 = 1430, C9 = 4862, C10 = 16796,
C11 = 58786, C12 = 208012, C13 = 742900, C14 = 2674440, C15 = 9694845.
The following formula is used to calculate the number of catlands:
- H (n) = H (n-1) * (4 * N-2)/(n + 1)
- H (n) = H (0) * H (n-1) + H (1) * H (n-2) +... + H (n-1) H (0) (N> = 2)
- H (n) = C (2n, N)/(n + 1) (n = 0, 1, 2 ,...)
- H (n) = C (2n, n)-C (2n, n + 1) (n = 0, 1, 2 ,...)
The following is an operation of the number of catlands: It can accurately calculate the number of catlands within 100.
/* For large numbers, the following algorithm should be used. Formula Used: H (n) = H (n-1) * (4 * N-2)/(n + 1 ); * // 0 Ms # include <iostream> # include <cstring> # include <stdio. h> using namespace STD; # define max 100 // maximum 10000 ^ 100, maximum 400 bits # define base 10000 void multiply (int A [], int Max, int B) // multiplication of large numbers, pay attention to the parameter passing {int I, array = 0; for (I = Max-1; I> = 0; I --) {array + = B * A [I]; A [I] = array % base; // the four-digit array with each digit storing a large number array/= base ;}} void divide (int A [], int Max, int B) // simulate the division of large numbers {int I, DIV = 0; for (I = 0; I <Max; I ++) {DIV = div * base + A [I]; A [I] = div/B; div % = B ;}} int main () {int A [101] [Max], I, n; memset (A [1], 0, max * sizeof (INT); for (I = 2, a [1] [MAX-1] = 1; I <101; I ++) // high coordinate storage of large numbers low position {memcpy (A [I], a [I-1], Max * sizeof (INT); // H [I] = H [I-1]; multiply (A [I], Max, 4 * I-2); // H [I] * = (4 * I-2); divide (A [I], Max, I + 1); // H [I]/= (I + 1);} while (CIN> N) {for (I = 0; I <Max & a [n] [I] = 0; I ++); // remove the number 0 before the array. Cout <a [n] [I ++]; // output the first non-zero number for (; I <Max; I ++) {printf ("% 04d ", a [n] [I]); // output the number following it, and each of them must be 4 characters in length! (32767)} cout <Endl;} return 0 ;}
I am very clear about the specific use of other blogs.
Below, I will only write what I think is a little interesting ......... 12 people stand in two rows of high and low, each row of people must be arranged in the order from low to high, and the second person in the first row must be tall. How many methods are available. We can think of this question as follows: 0 indicates in the first row, and 1 indicates in the second row. For example, 000000111111 indicates 1 2 3 4 5 6 7 8 9 10 11 12000110001111 indicates 1 2 3 6 7 8 4 5 9 10 11 12. how many conditions are arranged, it is obviously a problem of going into and out of the stack. So the answer to the question is catlan number (6)
[Catlan number] [number theory]