Time Limit: 1 Sec Memory Limit: 128 MB
shuoj 1016 接触神奇的卡特兰数\

传送门:SHUOJ1016

题解

神奇的递推公式: h(n)=h(n-1)(4n-2)/(n+1);
## AC code:(不包含输入类)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import java.util.*;  
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long[] catalan=new long [19];
catalan[0]=1;
catalan[1]=1;
while(sc.hasNext()){
int n=sc.nextInt();
for(int i=1;i<=n;i++){
catalan[i]=catalan[i-1]*(4*i-2)/(i+1);
}
System.out.println(catalan[n]);
}
}
}