1023

明显的卡特兰数:

http://baike.baidu.com/view/2499752.html

前几个数值:

1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796, 58786, 208012, 742900, 2674440, 9694845, 35357670, 129644790, 477638700, 1767263190, 6564120420, 24466267020, 91482563640, 343059613650, 1289904147324, 4861946401452, ...

递推的

h(n)=((4*n-2)/(n+1))*h(n-1);

递推解

h(n)=C(2n,n)/(n+1)

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


public class Main {

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

}

你可能感兴趣的:(c,String,Class,import)