题目链接: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. HDU 2602 Bone Collector (01背包DP)

    题意:给定一个体积,和一些物品的价值和体积,问你最大的价值. 析:最基础的01背包,dp[i] 表示体积 i 时最大价值. 代码如下: #pragma comment(linker, "/S ...

  2. C# 判断是否是在设计模式下有效的方法

    public static bool IsDesignMode() { bool returnFlag = false; #if DEBUG if (LicenseManager.UsageMode ...

  3. Promise实现简易AMD加载器

    在最新的Chrome和FF中已经 实现了Promise.有了Promise我们用数行代码即可实现一个简易AMD模式的加载器 var registry = { promises: { }, resolv ...

  4. Centos 安装编译codeblocks&&codelite

    codeblocks http://www.cnblogs.com/magialmoon/archive/2013/05/05/3061108.html http://wiki.codeblocks. ...

  5. 说一下自己对于 Linux 哲学的理解

    查阅了一些资料,官方的哲学思想貌似是: 一切皆文件 由众多单一目的的小程序,一个程序只实现一个功能,多个程序组合完成复杂任务 文本文件保存配置信息 尽量避免与用户交互 什么,你问我的理解?哲学思想?E ...

  6. Struts2的多方法动态Action

    原创 一个简单的Action里面的核心方法只有一个execute(); 定义多个核心方法的Action,有如下3种方式: 为Action配置method属性 动态方法调用 使用通配符映射方式 动态方法 ...

  7. 从Entity Framework的实现方式来看DDD中的repository仓储模式运用

    一:最普通的数据库操作 static void Main(string[] args) { using (SchoolDBEntities db = new SchoolDBEntities()) { ...

  8. 2014-3tomcat遇到的问题汇总

    tomcat启动不起来 端口占用:加了apache的ajp,所以要打开ajp_port,结果被占用了. 权限不够:chown:各个文件的权限都不够,特别是日志文件的. 配置问题:应用 servlet- ...

  9. vcenter安装错误The DSN is pointing to anunspported ODBC driver...

    在安装vcenter server中采用现有独立sql server数据库时出现下列错误. 这是由于当前独立数据库版本和当前系统的客户端驱动不匹配.导致我们在odbc中配置dsn无法正常运行. 如sq ...

  10. C#应用程序所有已经打开的窗体的集合

    获取所有打开的窗体的集合 Application.OpenForms 获取其中的某个窗体 Application.OpenForms["窗体名"]