看了下大牛们的,原来这题是卡特兰数,顺便练练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 Scanner(System.in);
BigInteger[] a=new BigInteger [205];
a[0]=a[1]=BigInteger.ONE;
for(int i=2;i<=200;i++){
a[i]=BigInteger.ZERO;
for(int j=0;j<i;j++){
a[i]=a[j].multiply(a[i-j-1]).add(a[i]);
}
//System.out.println(a[i]);
}
while(true){
int n=in.nextInt();
if(n==-1)
break;
System.out.println(a[n]);
}
} }

POJ 2084 Game of Connections 卡特兰数的更多相关文章

  1. (组合数学3.1.2.2)POJ 2084 Game of Connections(卡特兰数公示的实现)

    package com.njupt.acm; import java.math.BigInteger; import java.util.Scanner; public class POJ_2084 ...

  2. POJ 2084 Game of Connections(卡特兰数)

    卡特兰数源于组合数学,ACM中比较具体的使用例子有,1括号匹配的种数.2在栈中的自然数出栈的种数.3求多边形内三角形的个数.4,n个数围城圆圈,找不相交线段的个数.5给定n个数,求组成二叉树的种数…… ...

  3. POJ2084 Game of Connections 卡特兰数 关于卡特兰数经典的几个问题

    Game of Connections Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 9128   Accepted: 44 ...

  4. POJ 2084 Game of Connections

    卡特兰数. #include<stdio.h> #include<string.h> ; ; void mul(__int64 a[],int len,int b) { int ...

  5. POJ 2084 Catalan数+高精度

    POJ 2084 /**************************************** * author : Grant Yuan * time : 2014/10/19 15:42 * ...

  6. 组合数学的卡特兰数 TOJ 3551: Game of Connections

    这个就是卡特兰数的经典问题 直接用这个公式就好了,但是这个题涉及大数的处理h(n)=h(n-1)*(4*n-2)/(n+1) 其实见过好几次大数的处理了,有一次他存的恰好不多于30位,直接分成两部分l ...

  7. poj——2084  Game of Connections

    Game of Connections Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 8664   Accepted: 42 ...

  8. HDU 1134 Game of Connections(卡特兰数+大数模板)

    题目代号:HDU 1134 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1134 Game of Connections Time Limit: 20 ...

  9. poj 1095 Trees Made to Order 卡特兰数

    这题用到了卡特兰数,详情见:http://www.cnblogs.com/jackge/archive/2013/05/19/3086519.html 解体思路详见:http://blog.csdn. ...

随机推荐

  1. cento 7使用minicom串口调试工具

    cento 7使用minicom串口调试工具   因为要使用串口配置设备,所以考虑要用串口管理软件,windows下比较容易了,直接用超级终端也好,用CRT也可以,CentOS系统稍微麻烦一点,前几天 ...

  2. XRDP freerdp

    服务器上 freerdp 桌面上有XRDP

  3. coverage report

    转载:http://blog.sina.cn/dpool/blog/s/blog_7853c3910102yn77.html VCS仿真可以分成两步法或三步法, 对Mix language, 必须用三 ...

  4. Scala 中的可变(var)与不可变(val)

    引言 Scala 中定义变量分为 var(可变变量)和 val(不可变变量) Scala 中集合框架也分为可变集合和不可变集合.比如 List(列表) 和 Tuple(元组)本身就是不可变的,set ...

  5. shell应用之习题一

    1 #!/bin/bash 2 #.写一个脚本/root/bin/argsnum.sh,接受一个文件路径作 为参数:如果参数个数小于1,则提示用户"至少应该给一个 参数",并立即退 ...

  6. 如何屏蔽 iOS 软件自动更新,去除更新通知和标记

    适用于 iOS.iPadOS 和 watchOS,即 iPhone.iPad 和 Apple Watch 通用. 请访问原文链接:https://sysin.org/article/Disable-i ...

  7. MongoDB学习笔记:文档Crud Shell

    MongoDB学习笔记:文档Crud Shell   文档插入 一.插入语法 db.collection.insertOne() 将单个文档插入到集合中.db.collection.insertMan ...

  8. IOS IAP 自动续订 之 利用rabbitmq延时队列自动轮询检查是否续订成功

    启用针对自动续期订阅的服务器通知: - 官方地址: - https://help.apple.com/app-store-connect/#/dev0067a330b - 相关字段, 相关类型地址:  ...

  9. TVM性能评估分析(二)

    TVM性能评估分析(二) Figure 1.  A bird's eye view of the µTVM + AutoTVM infrastructure Figure 2.  A standard ...

  10. Tengine Framework基础

    Tengine Framework基础 最受开发者喜爱的边缘AI计算框架 Tengine是OPEN AI LAB推出的自主知识产权的边缘AI计算框架,致力于解决AIoT产业链碎片化问题,加速AI产业化 ...