卡特兰数模板题,卡特兰数是解决递归问题的很有用的结论,注意这道题需要高精度,可以用java大数水过去

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

public class Main 
{
    BigInteger [][] c = new BigInteger[202][202];
    public  void init ( )
    {
        c[1][1] = c[1][0] =c[0][0] = BigInteger.ONE;
         for ( int i = 2 ; i <=  200 ; i++ )
             for ( int j = 0 ; j <= i ; j++ )
                 if ( j == 0 || j == i ) c[i][j] = BigInteger.ONE;
                 else c[i][j] = c[i-1][j-1].add(c[i-1][j]);
    }
    
    public static  void main ( String args[]  )
    {
        Main a = new Main ();
        a.init();
        Scanner cin = new Scanner ( System.in );
        while ( cin.hasNext() )
        {
            int n = cin.nextInt();
            System.out.println ( a.c[2*n][n].divide(BigInteger.valueOf(n+1)) );
        }
    }
}