hdu 1130 卡特兰数加大数
发布时间:2020-12-14 04:53:56 所属栏目:大数据 来源:网络整理
导读:以后大数用java的BigInteger类好了 代码 /* * create by zzy at 2017,2:03:40 PM */ import java.math.BigInteger;import java.util.Scanner; public class Main { static int max= 105 ; static BigInteger[]h= new BigInteger[max]; public static void ge
以后大数用java的BigInteger类好了 代码 /* * create by zzy at 2017,2:03:40 PM */
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
static int max=105;
static BigInteger[]h=new BigInteger[max];
public static void getCatlanten(){
h[0]=BigInteger.valueOf(1);
h[1]=BigInteger.valueOf(1);
for(int i=2;i<max;i++){
//hn=(4*n-2)/(n+1) *h[n-1]
h[i]=h[i-1].multiply(BigInteger.valueOf(4*i-2)).divide(BigInteger.valueOf(i+1));
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
int n;
getCatlanten();
while(in.hasNextInt()){
n=in.nextInt();
System.out.println(h[n]);
}
}
}
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |