Catalan Numbers

5

2 votes
Problem

In combinatorial mathematics, the Catalan numbers form a sequence of natural numbers that occur in various counting problems, often involving recursively-defined objects. They are named after the Belgian mathematician Eugène Charles Catalan (1814–1894).

An alternative expression for Cn is

enter image description here

The Catalan numbers satisfy the recurrence relation

enter image description here

moreover,

enter image description here


Input Format:
The first line of input consists of an integer Q . Then follow Q lines, each containing an integer X.


Output Format:
For each query X, output a line containing CX, the Xth Catalan number.


Constraints:
1 ≤ Q ≤ 1000
1 ≤ X ≤ 5000

Sample Input
6
1
2
3
4
5
50
Sample Output
1
2
5
14
42
1978261657756160653623774456
Time Limit: 2
Memory Limit: 256
Source Limit:
Contributers:
Editor Image

?