http://acm.hdu.edu.cn/showproblem.php?pid=1023
卡特兰数,要注意是大数,直接学着用java搞大数了
View Code
import java.io.*; import java.math.*; import java.util.*; import java.text.*; public class Main { public static void main(String[] args) { Scanner cin=new Scanner (new BufferedInputStream(System.in)); BigInteger[] f=new BigInteger[103]; f[0]=f[1]=f[2]=BigInteger.valueOf(1); for(int i=2;i<102;i++) f[i+1]=BigInteger.valueOf(4).multiply(BigInteger.valueOf(i)).subtract(BigInteger.valueOf(6)).multiply(f[i]).divide(BigInteger.valueOf(i)); while(cin.hasNext()) { int n=cin.nextInt(); System.out.println(f[n+2]); } } }