JAVA 卡特兰数

import java.util.*;
import java.math.*;

public class Main{
    
       
    public static void main(String[] args) { 
        BigInteger[] Cal = new BigInteger[6000];   
        Scanner in = new Scanner(System.in); 
        int n=in.nextInt(); 
        Cal[0]=BigInteger.ONE; 
        Cal[1]=BigInteger.ONE; 
           
        for(int i=2;i<=5100;i++) 
        { 
            BigInteger v1=BigInteger.valueOf(2*i*(2*i-1)); 
            BigInteger v2=BigInteger.valueOf(i*(i+1)); 
            Cal[i]=Cal[i-1].multiply(v1).divide(v2); 
        } 
        System.out.println(Cal[n]);  
    } 
}

 

posted on 2016-11-04 20:02  very_czy  阅读(415)  评论(0编辑  收藏  举报

导航