不要过于沉溺过去,也不要过于畅想未来,把握现在!

POJ 2084 Catalan数+高精度

POJ 2084

/****************************************
 *       author        :  Grant Yuan
 *       time            :   2014/10/19 15:42
 *       source       :    POJ 2084
 *       algorithm:     Catalan数+高精度
 * ***************************************/
import java.io.*; 
import java.math.*;
import java.util.*;
public class Main{
	public static void main(String args[])
	{
		Scanner cin=new Scanner(System.in); 
		BigInteger []a = new BigInteger [105];
		BigInteger t;
		a[0]=a[1]=BigInteger.ONE;
		for(int  i=2;i<=102;i++)
		{
			a[i]=a[i-1].multiply(BigInteger.valueOf(4*i-2)).divide(BigInteger.valueOf(i+1));
		}
		while(true){
			int n=cin.nextInt();
			if(n==-1) break;
			String str;
			str=a[n].toString();
			System.out.println(str);
		}
	}
}


posted @ 2014-10-19 15:44  coding_yuan  阅读(132)  评论(0编辑  收藏  举报

不要过于沉溺过去,也不要过于畅想未来,把握现在!