看了下大牛们的,原来这题是卡特兰数,顺便练练java.递归式子:h(0)=1,h(1)=1   h(n)= h(0)*h(n-1) + h(1)*h(n-2) + ... + h(n-1)h(0) (其中n>=2)   打表172MS import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in=new S…
package com.njupt.acm; import java.math.BigInteger; import java.util.Scanner; public class POJ_2084 { public static void main(String[] args) { BigInteger catalan[] = new BigInteger[102]; catalan[1] = new BigInteger("1"); BigInteger one = new Big…
卡特兰数源于组合数学,ACM中比较具体的使用例子有,1括号匹配的种数.2在栈中的自然数出栈的种数.3求多边形内三角形的个数.4,n个数围城圆圈,找不相交线段的个数.5给定n个数,求组成二叉树的种数…… 此题就是第4个样例,是裸卡特兰数,但是这里牵扯的大数,可以使用java的大数类解决,但是我这里使用高精度乘法和除法模拟的(主要是java不会). 此处的递推式为H[1] = 1:H[n] = H[n-1]*(4*n-2)/(n+1){n>=2}:代码如下: 需要注意输出的形式,我这里的进制是100…
Game of Connections Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 9128   Accepted: 4471 Description This is a small but ancient game. You are supposed to write down the numbers 1, 2, 3, . . . , 2n - 1, 2n consecutively in clockwise ord…
卡特兰数. #include<stdio.h> #include<string.h> ; ; void mul(__int64 a[],int len,int b) { int i; __int64 jw=; ;i>=;i--) { jw=jw+a[i]*b; a[i]=jw%base; jw=jw/base; } } void div(__int64 a[],int len,int b) { int i; __int64 jw=; ;i<lenth;i++) { jw…
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.*; publ…
这个就是卡特兰数的经典问题 直接用这个公式就好了,但是这个题涉及大数的处理h(n)=h(n-1)*(4*n-2)/(n+1) 其实见过好几次大数的处理了,有一次他存的恰好不多于30位,直接分成两部分long long 存了 这个只涉及到大数乘小数,大数除以小数,所以比较简单些 3551: Game of Connections  Time Limit(Common/Java):1000MS/3000MS     Memory Limit:65536KByteTotal Submit: 5    …
Game of Connections Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 8664   Accepted: 4279 Description This is a small but ancient game. You are supposed to write down the numbers 1, 2, 3, . . . , 2n - 1, 2n consecutively in clockwise ord…
题目代号:HDU 1134 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1134 Game of Connections Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4668    Accepted Submission(s): 2729 Problem Description Thi…
这题用到了卡特兰数,详情见:http://www.cnblogs.com/jackge/archive/2013/05/19/3086519.html 解体思路详见:http://blog.csdn.net/lvlu911/article/details/5425974 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include<iomanip> #include<cm…