hdu 1023 Train Problem II 卡特兰数+java

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

public class Main {

    /** * @param args */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner cin= new Scanner(System.in);
        int n=0;
        while(cin.hasNextInt())
        {
            n=cin.nextInt();
            int i=0;
            BigInteger ans=BigInteger.ONE;
            for(i=1;i<=n;i++)
            {
                ans=ans.multiply(BigInteger.valueOf(4*i-2));
                ans=ans.divide(BigInteger.valueOf(i+1));
            }
        System.out.println(ans);
        }

    }

}

你可能感兴趣的:(hdu 1023 Train Problem II 卡特兰数+java)