题目链接: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. 说说JVM中的操作码

    JVM操作码 加载与存储操作码 load --从局部变量加载值到栈上 ldc --从池中加载常量到栈上 store --把值从栈中移走,存到局部变量中 dup --复制栈顶的值 getField -- ...

  2. 编写高质量代码改善C#程序的157个建议——建议109:谨慎使用嵌套类

    建议109:谨慎使用嵌套类 使用嵌套类的原则是:当某类型需要访问另一个类型的私有成员时,才将它实现为嵌套类.一个典型的例子是在实现集合时,要为集合实现迭代器,这时用到了嵌套类.代码如下所示: publ ...

  3. mysql 查询条件

    1简单查询   select* from 表名 select name as“姓名”fromstu     (把name改为名字) 2条件查询 where 后面跟条件  条件要写清楚 3模糊查询  l ...

  4. C/C++ Pthread线程

    线程按照其调度者可以分为用户级线程和核心级线程两种 用户级线程主要解决的是上下文切换的问题,它的调度算法和调度过程全部由用户自行选择决定,在运行时不需要特定的内核支持: 我们常用基本就是用户级线程,所 ...

  5. idea中java文件打包出去步骤

     打包出去之后 通过xftp放在Linus上面去运行 然后用hadoop fs -put 放到hadoop集群上面(而且此时在/user/hadoop下面创建好input文件夹和一个输入的文件) 即 ...

  6. Tomcat负载均衡原理详解及配置(Apache2.2.19+Tomcat7.0.12)

    结构图 JAVA项目一般直接用Tomcat作为Web服务器.为了增加tomcat的性能和稳定性,我们一般采用balance和session同步机制. 下图列出了我们常用也是最简单的解决方案. 说明 1 ...

  7. PMBOK项目管理相关知识梳理

    该次梳理,依据PMBOK(第五版),罗列项目管理十三章节重要的知识点. 一.引论1.项目的定义与举例:2.项目.项目组合.项目集与项目组织管理:3.范进本质是风资(范围.进度.成本.质量.风险.资源) ...

  8. c# 跨线程访问窗体UI

    定义个结构体用于存储线程中传递的参数信息 struct ImgInfo { public string url; public string path; }; 参数传递到线程中 ImgInfo img ...

  9. HAOI2010 订货

    题目链接:戳我 费用流. 将每天分成早上和晚上两个点.源点向早上连容量INF,费用为进货量的边.早上向汇点连容量供货量,费用0.早上向晚上连容量为S,费用为0的边.晚上向第二天早上连容量S,费用0.之 ...

  10. eclipse - maven使用国内镜像

    1 使用 maven 插件 - 官网下载 2 修改 eg : apache-maven-3.6.0-bin\apache-maven-3.6.0\conf\ setting.xml - 可备份下 3 ...