Train Problem II

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7918    Accepted Submission(s):
4241

Problem Description
As we all know the Train Problem I, the boss of the
Ignatius Train Station want to know if all the trains come in strict-increasing
order, how many orders that all the trains can get out of the railway.
 
Input
The input contains several test cases. Each test cases
consists of a number N(1<=N<=100). The input is terminated by the end of
file.
 
Output
For each test case, you should output how many ways
that all the trains can get out of the railway.
 
Sample Input
1
2
3
10
 
Sample Output
1
2
5
16796
 
出栈问题。卡特兰数。
用java解决大数是多么的方便啊!!!
第一个java程序。
 
import java.util.*;
import java.math.BigInteger; public class Main { public static void main(String[] args) {
BigInteger[] a=new BigInteger[105];
a[0]=BigInteger.valueOf(1);
a[1]=BigInteger.valueOf(1);
for(int i=2;i<=100;i++)
a[i]=BigInteger.valueOf(0);
for(int i=2;i<=100;i++)
for(int j=1;j<=i;j++)
a[i]=a[i].add(a[j-1].multiply(a[i-j]));
//System.out.println(a[10]);
Scanner in =new Scanner(System.in);
int n;
while(in.hasNext())
{
n=in.nextInt();
System.out.println(a[n]);
}
} }
j

HDU_1023_Train Problem II_卡特兰数的更多相关文章

  1. hdu1032 Train Problem II (卡特兰数)

    题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能.    (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...

  2. HDU-1023 Train Problem II 卡特兰数(结合高精度乘除)

    题目链接:https://cn.vjudge.net/problem/HDU-1023 题意 卡特兰数的应用之一 求一个长度为n的序列通过栈后的结果序列有几种 思路 一开始不知道什么是卡特兰数,猜测是 ...

  3. C - Train Problem II——卡特兰数

    题目链接_HDU-1023 题目 As we all know the Train Problem I, the boss of the Ignatius Train Station want to ...

  4. HDU 1023 Train Problem II (卡特兰数,经典)

    题意: 给出一个数字n,假设火车从1~n的顺序分别进站,求有多少种出站序列. 思路: 卡特兰数的经典例子.n<101,用递推式解决.需要使用到大数.n=100时大概有200位以下. #inclu ...

  5. HDOJ 1023 Train Problem II 卡特兰数

    火车进站出站的问题满足卡特兰数...卡特兰数的相关知识如下: 卡特兰数又称卡塔兰数,是组合数学中一个常出现在各种计数问题中出现的数列.由以比利时的数学家欧仁·查理·卡塔兰 (1814–1894)命名. ...

  6. HDU 1023 Traning Problem (2) 高精度卡特兰数

    Train Problem II Time Limit: 1000MS   Memory Limit: 32768KB   64bit IO Format: %I64d & %I64u Sub ...

  7. Train Problem II(卡特兰数+大数乘除)

    Train Problem II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  8. 1023 Train Problem II(卡特兰数)

    Problem Description As we all know the Train Problem I, the boss of the Ignatius Train Station want ...

  9. HDU 1023 Train Problem II (大数卡特兰数)

    Train Problem II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

随机推荐

  1. 在docker上安装运行mysql实例

    ps:实验环境是:CentOS Linux release 7.3  64位1.获取mysql镜像从docker hub的仓库中拉取mysql镜像docker pull mysql查看镜像docker ...

  2. 人人都是 DBA

    http://www.cnblogs.com/gaochundong/tag/DBA/

  3. Centos: Screen tips

    Install yum install screen Useful screen commands List a particular users screen sessions: screen -l ...

  4. linux系统下安装R

    一.先通过ssh将R安装包R-3.2.2.tar.gz从本机复制到你的linux虚拟机上的/home下: 二.解压安装包 #tar -zxvf R-3.2.2.tar.gz 三.1).进入到解压后的R ...

  5. CI 日志类

    开发ci的过程中,使用log能直观的看出代码运行到哪,还可设置代码查看数据接口的发送情况.日志类: <?php defined('BASEPATH') OR exit('No direct sc ...

  6. 这篇讲angular 的$q的讲得不错

    原文: https://segmentfault.com/a/1190000000402555 ---------------------------------------------------- ...

  7. poj 3020 Antenna Placement(二分无向图 匈牙利)

    Antenna Placement Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6438   Accepted: 3176 ...

  8. 第14章4节《MonkeyRunner源代码剖析》 HierarchyViewer实现原理-装备ViewServer-port转发

    在初始化HierarchyViewer的实例过程中,HierarchyViewer会调用自己的成员方法setupViewServer来把ViewServer装备好,那么我们这里先看下这种方法: 39 ...

  9. opencv中RGB转HSV

    cvCvtColor(src,dst,CV_BGR2HSV); 当中,src为三通道的,dst也为三通道的. OPENCV 中 H.S.V.顺序分别为3*x+0  3*x+1   3*x+2 open ...

  10. Oracle行转列,列转行,行列相互转换

    1.行转列 SELECT WM_CONCAT(COLUMN_NAME) COLUMN_NAME FROM USER_TAB_COLUMNS WHERE TABLE_NAME = 'T_CREATE_T ...