1.

/**
* Angewandte Mathematik, SS09, IFB 2C
* ACM Problem #10303 (How Many Trees?)
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=15&page=show_problem&problem=1244
*
* @author Christian Posselt
* @author Jonathan Schubert
* @author Doina Logofatu(Algorithmen und Problemlösungen mit C++ von der diskreten Mathematik )
* @version 1.1, 06/08/2009
*
* Status : Accepted
* Runtime: 1.024
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.StringTokenizer;


class Main
{
public static void main(String[] args) throws IOException
{
// Algorithm based on book (Algorithmen und Problemlösungen mit C++)
// by Doina Logofatu
// Page 200
int limit = 1000; // upper limit for array
ArrayList<BigInteger> res = new ArrayList<BigInteger>(); //array with catalan numbers
res.add(new BigInteger("1"));
for(int index = 0; index <= limit; index ++) //calculate all catalan numbers between 0 and upper limit
{
BigInteger T = new BigInteger("0");
for(int j=0;j<index;j++)
{
T = T.add(res.get(j).multiply(res.get(index-1-j)));
}
if(!T.equals(BigInteger.ZERO))
res.add(T);
}
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
StringBuilder builder = new StringBuilder();
while(true)
{
String line = reader.readLine();
if(line == null)
break;
StringTokenizer token = new StringTokenizer(line);
while(token.hasMoreTokens())
builder.append(res.get(Integer.parseInt(token.nextToken()))+"\n");
}
builder.deleteCharAt(builder.length()-1);
System.out.println(builder.toString());
}
}


2.


/**
* Angewandte Mathematik, SS09, IFB 2C
* ACM Problem: How Many Trees (10303)
* @author Christian Mitterreiter
* @author Rolf Luigs
* @version 1.0, 05/12/2009
* Status : Accepted
* Runtime: 0.288
*/


import java.math.BigInteger;
import java.util.Scanner;

public class Main {

public static BigInteger fak (BigInteger z) { //Fakultät berechnen
BigInteger ret = new BigInteger("1");
BigInteger eins = new BigInteger("1");
BigInteger i = new BigInteger("1");

for(;!i.equals(z);i=i.add(eins)) {
ret=ret.multiply(i);
}
return ret=ret.multiply(i);
}


public static void main(String[] args) {

Scanner sc = new Scanner(System.in);
BigInteger zwei = new BigInteger("2");

while(sc.hasNext()) {

BigInteger n = sc.nextBigInteger();
BigInteger t1 = fak(zwei.multiply(n));
BigInteger t2 = fak(n.add(BigInteger.ONE)).multiply(fak(n));

System.out.println(t1.divide(t2)); //Catalan number
}
}
}