http://acm.hdu.edu.cn/showproblem.php?pid=1131
求N个不同结点的组成的树的种类
卡特兰数求出 树的结构 的个数,乘以结点的阶乘
import java.io.*;
import java.math.*;
import java.util.*;
public class Main{
public static void main(String []args){
Scanner cin = new Scanner(System.in);
Integer N = 101,i;
BigInteger []cat = new BigInteger[N];
BigInteger []fac = new BigInteger[N];
fac[1] = cat[1] = BigInteger.valueOf(1);
for(i = 2; i < N; ++i){
fac[i] = fac[i-1].multiply(BigInteger.valueOf(i));
cat[i] = cat[i-1].multiply(BigInteger.valueOf(i*4-2)).divide(BigInteger.valueOf(i+1));
}
while(cin.hasNext()){
i = cin.nextInt();
if(i == 0)
break;
System.out.println(fac[i].multiply(cat[i]));
}
}
}