题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1023

Train Problem II

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

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

Hint

The result will be very large, so you may not process it by 32-bit integers.

 
Author
Ignatius.L
 
Recommend
We have carefully selected several similar problems for you:  1133 1022 1130 1131 1134 
 
题目大意:问你有n辆火车,要求进站顺序是1-n  问你有多少种出站次序
思路:要用到大数,所以推荐用java来写,方便很多。  这题就是一个卡特兰数的板子
看代码:
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner cin = new Scanner(System.in); /*
* 卡特兰数性质:h[n]=h[n-1]*(4n-2)/(n+1)
*/
BigInteger dp[] = new BigInteger[150];
dp[1]=BigInteger.valueOf(1);
for(int i=2;i<=100;i++) {
dp[i]=dp[i-1].multiply(BigInteger.valueOf(4*i-2)).divide(BigInteger.valueOf(i+1));
} while(cin.hasNext()) {
int n=cin.nextInt();
System.out.println(dp[n]);
}
}
}

Train Problem II(卡特兰数 组合数学)的更多相关文章

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

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

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

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

  3. HDOJ 1023 Train Problem II 卡特兰数

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

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

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

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

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

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

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

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

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

  8. (母函数 Catalan数 大数乘法 大数除法) Train Problem II hdu1023

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

  9. hdu 1023 Train Problem II

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1212 Train Problem II Description As we all know the ...

随机推荐

  1. SSH 密钥登录 SecureCRT

    https://www.qcloud.com/doc/product/213/2036 1.3. 使用SecureCRT登录 1.3.1. 复制公钥 登录腾讯云控制台,点击[云服务器]-[SSH密钥] ...

  2. unittest测试框架详谈及实操(三)

    断言 unittest的TestCase类提供了很多实用的方法来校验预期结果和程序返回的实际结果是否一致.当然这些方法要求必须满足某些条件才能继续执行接下的测试.大致有3种这样的方法.各覆盖一个特定类 ...

  3. SOAP协议初级指南 (一)

    SOAP(Simple Object Access Protocal) 技术有助于实现大量异构程序和平台之间的互操作性,从而使存在的应用能够被广泛的用户所访问.SOAP是把成熟的基于HTTP的WEB技 ...

  4. Gym - 100989H (贪心)

    After the data structures exam, students lined up in the cafeteria to have a drink and chat about ho ...

  5. CodeForces 620E New Year Tree(线段树的骚操作第二弹)

    The New Year holidays are over, but Resha doesn't want to throw away the New Year tree. He invited h ...

  6. [教学] Log.d 日志调试查看(所有平台)

    Firemonkey 提供了一个跨平台的日志显示函数 Log.d,当 App 越来越大 Debug 编译越来越慢时,可以利用它在 Release 模式来除错,下列说明如何在各平台查看. 小技巧:可以在 ...

  7. Centos操作系统配置VIP以及网络

    打开虚拟机的网络配置文件 vi /etc/sysconfig/network-script/ifc*** (具体文件根据情况自行填写) 编辑这个文件添加入如下配置 IPADDR=ip地址 (添加VIP ...

  8. php的数组汉字符串常用函数

    <?php// function add($a,$b,$func){// if(!is_callable($func)){// return false;// }// $m=$a+$b+$fun ...

  9. [raspberry p3] [suse] 安装maven

    [raspberry p3] [suse] 安装maven 配置package repositroy, 添加devel:tools:building vim /etc/zypp/repos.d/ope ...

  10. [Erlang11] 那些经历过的Erlang小坑11-20

    11.每次重装系统时都会重新安装Erlang,Ubuntu安装sh秒杀一切. https://gist.github.com/zhongwencool/11174620 12. Erlang Shel ...