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. Ubuntu 16.04中CPU轮流100%的问题解决

    刚装好Ubuntu 16.04,但是观察各个CPU都是轮流100%,如图所示:

  2. Spring实现封装自定义注解@Trimmed清除字符串前后的空格

    在Spring中实现字符串清除的方法有很多,原生方法String自带trim()方法,或者使用StringUtils提供的trim...方法. 通常可以将上面的方式封装成自定义注解的形式去实现来节省更 ...

  3. gn3 --iou

    http://www.wyzc.com/Course/Course/learnAction/id/14049/center/0#lesson/400847 http://www.mamicode.co ...

  4. eventlet

    项目中要模拟openstack的swift的多路write功能.初步设想是用python的eventlet来实现多线程.比如在write的时候要同时写入两个storage,就用eventlet生成2个 ...

  5. PayPal加密证书.pem的生成

    How do I create a public certificate for use with PayPal Encrypted Website Payments?   Before you ca ...

  6. Cisco路由器配置ADSL上网

    cisco1841#sh run Building configuration... Current configuration : 2970 bytes ! version 12.4 service ...

  7. C#程序猿学习 Python

    孙广东  2016.1.1 交互: C# 运行Python代码: http://stackoverflow.com/questions/11779143/run-a-python-script-fro ...

  8. cocos2d-x 3.0 常见问题及解决

    我自己遇到的问题记录,会及时更新.希望对大家有帮助 1.打包图片生成plist后,假设在游戏中图片挨在一起可能会出现黑线,打包时将Extrude设为1就可以 2.Xcode环境下.更新资源后执行的时候 ...

  9. 对RDD分区的理解

    举个例子: val logFile = "file:///home/soyo/桌面/6.txt" val conf = new SparkConf().setAppName(&qu ...

  10. E20170620-hm

    dump  n. 垃圾场; 仓库; 无秩序地累积;  vt. 倾倒; 倾销; 丢下,卸下; 摆脱,扔弃; terminate   vt. 结束; 使终结; 解雇; 到达终点站; adj. 结束的; d ...