思路:
关于卡特兰数:
递推公式:C(n)=C(n-1)*((4*n-2)/(n+1));
import java.math.BigInteger;
import java.util.*;
public class Main {
public static void main(String[] args) {
String s, L;
BigInteger Catalan[] = new BigInteger[5001];
Catalan[0] = Catalan[1] = BigInteger.valueOf(1);
BigInteger one = BigInteger.valueOf(1);
BigInteger two = BigInteger.valueOf(2);
BigInteger four = BigInteger.valueOf(4);
Scanner cin = new Scanner(System.in);
int n = cin.nextInt();
for (int i = 2; i <= n; i++) {
Catalan[i] = Catalan[i - 1].multiply(((BigInteger.valueOf(i).multiply(four)).subtract(two)))
.divide(BigInteger.valueOf(i).add(one));
}
BigInteger ans = BigInteger.valueOf(0);
for (int i = 0; i <= n; i++) {
ans = ans.add(Catalan[i].multiply(Catalan[n - i]));
}
System.out.print(ans);
}
}