标签:style blog http color io os ar java for
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=948
卡特兰数*n!
1 import java.math.BigInteger; 2 import java.util.*; 3 public class Main { 4 public static void main(String[]args) 5 { 6 Scanner cin=new Scanner(System.in); 7 BigInteger []a=new BigInteger[1000]; 8 a[0]=BigInteger.valueOf(1); 9 for(int i=1; i<=300; i++) 10 { 11 int m=(4*i-2); 12 a[i]=a[i-1].multiply(BigInteger.valueOf(m)); 13 a[i]=a[i].divide(BigInteger.valueOf(i+1)); 14 } 15 int n; 16 while(cin.hasNext()) 17 { 18 n=cin.nextInt(); 19 if(n==0) break; 20 BigInteger ans=BigInteger.valueOf(1); 21 for(int i=1; i<=n; i++) 22 { 23 ans=ans.multiply(BigInteger.valueOf(i)); 24 } 25 ans=ans.multiply(a[n]); 26 System.out.println(ans); 27 } 28 } 29 }
标签:style blog http color io os ar java for
原文地址:http://www.cnblogs.com/fanminghui/p/4016882.html