【HDOJ】1134 Game of Connections
2014-12-26 11:16
288 查看
Catlan数。
/* 1134 */ import java.util.Scanner; import java.math.BigInteger; /* Catalan: (1) h(n) = h(n-1) * (4*n-2) / (n+1) (2) h(n) = C(2n, n) / (n+1) (3) h(n) = C(2n, n) - C(2n, n+1) */ public class Main { public static void main(String args[]) { Scanner cin = new Scanner(System.in); BigInteger[] bi = new BigInteger[MAXN]; bi[1] = BigInteger.ONE; bi[2] = BigInteger.valueOf(2); for (int i=3; i<MAXN; ++i) { BigInteger x = BigInteger.valueOf(4*i-2); BigInteger y = BigInteger.valueOf(i+1); bi[i] = bi[i-1].multiply(x).divide(y); } int n; while (cin.hasNext()) { n = cin.nextInt(); if (n == -1) break; System.out.println(bi ); } } public static final int MAXN = 101; }
相关文章推荐
- hdu/hdoj 1134 Game of Connections
- HDOJ 1134 Game of Connections 简单解题报告
- hdoj-1134-Game of Connections【卡特兰数】
- hdoj 1134 Game of Connections【水】【java】
- HDOJ HDU 1134 Game of Connections
- HDU 1134 Game of Connections
- hdu 1134 Game of Connections(卡特兰(Catalan)公式)
- HDU 1134 Game of Connections (高精度卡特兰数)
- [ACM] hdu 1134 Game of Connections(大数+Catalan数)
- HDU1134 Game of Connections(大数乘法+打表)
- hdu 1134 Game of Connections
- [Catalan] HDU 1134 Game of Connections
- [ACM] hdu 1134 Game of Connections(大数+Catalan数)
- HDU ACM 1134 Game of Connections / 1130 How Many Trees?(卡特兰数)
- HDU 1134 Game of Connections
- hdu 1134 game of connections(Catalan Number)
- [ACM] hdu 1134 Game of Connections(大数+Catalan数)
- hdu-1134-Game of Connections(卡特兰数 大数乘法除法)
- hdu1134 Game of Connections 卡特兰数(大数)
- hdu 题目1134 Game of Connections (卡塔兰数 catalan number)