题目链接: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. 团体程序设计天梯赛L2-003 月饼 2017-03-22 18:17 42人阅读 评论(0) 收藏

    L2-003. 月饼 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 月饼是中国人在中秋佳节时吃的一种传统食品,不同地区有许多不 ...

  2. route -A inet6 增加下一跳 提示错误 SIOCADDRT: No route to host

    1.增加前路由表: 2. route -A inet6 增加下一跳 提示错误 SIOCADDRT: No route to host 3.删除已有的下一条路由表项: 4.再次尝试 route -A i ...

  3. jQuery获取各种input输入框的值

    1.获取一组radio单选框的值(name属性为一组的radio的name属性) var q1 = $("input[name=element_name]:checked").va ...

  4. scvmm应答文件 无人值守安装系统

    我们可以通过这种windows配置文件实现winpe.光盘等无人职守安装配置操作系统,在scvmm虚拟化平台中这种文件叫做应答文件. 下面为一个windows server 2008 r2的一个完整应 ...

  5. C# Email 发送邮件,对方打开通知你

    直接上代码: //回执地址 var Receipt = "填写你需要回执的地址"; //实例化两个必要的 MailMessage mail = new MailMessage(); ...

  6. 【Selenium专题】 FAQ_对象识别_Compound class names are not supported

    测试代码 public void login(){ WebDriver driver = new ChromeDriver(); driver.get("http://IP:Port/cli ...

  7. C++的可移植性和跨平台开发

    概述 今天聊聊C++的可移植性问题.如果你平时使用C++进行开发,并且你对C++的可移植性问题不是非常清楚,那么我建议你看看这个系列.即使你目前没有跨平台开发的需要,了解可移植性方面的知识对你还是很有 ...

  8. OCP 052题库全变,最新052考试题及答案整理-第11题

    11.Which three are true about UNDO data? A) It is used to roll back failed transactions. B) It is us ...

  9. How to Mount a Remote Folder using SSH on Ubuntu

    Connecting to a server across the internet is much more secure using SSH. There is a way that you ca ...

  10. 洛谷P3643 [APIO2016]划艇(组合数学)

    题面 传送门 题解 首先区间个数很少,我们考虑把所有区间离散化(这里要把所有的右端点变为\(B_i+1\)代表的开区间) 设\(f_{i,j}\)表示考虑到第\(i\)个学校且第\(i\)个学校必选, ...