题目链接: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]);}}
}

转载于:https://www.cnblogs.com/caijiaming/p/10724785.html

Train Problem II(卡特兰数 组合数学)相关推荐

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

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

  2. Train Problem II 卡特兰裸题(入门题)

    Train Problem II  题目大意:给你一个数n,表示有n辆火车,编号从1到n,从远方驶过来,问你有多少种出站的可能. 解题思路:模拟栈的问题而已.  卡特兰问题. 1 import jav ...

  3. hdu 1023 Train Problem II

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

  4. HDU1023 Train Problem II

    传送门https://vjudge.net/problem/HDU-1023 解题思路: 大数和卡特兰数 实现代码: #include <iostream> #include <cs ...

  5. HDU1023 Train Problem II【Catalan数】

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1023 题目大意: 一列N节的火车以严格的顺序到一个站里.问出来的时候有多少种顺序. 解题思路: 典型 ...

  6. 【HDOJ】1023 Train Problem II_天涯浪子_新浪博客

    [题目]http://acm.hdu.edu.cn/showproblem.php?pid=1023 [报告] 简单粗暴的卡特兰数,不过要用大数才能过呦~ [程序] // Task: 1023 Tra ...

  7. 《组合数学》——卡特兰数

    我们结合一个题目具体看看Catalan数的应用.(Pr0blem source:hdu2067) Problem Description 小兔的叔叔从外面旅游回来给她带来了一个礼物,小兔高兴地跑回自己 ...

  8. 【组合数学】卡特兰数 / 大施罗德数 相关

    在组合数学中,施罗德数用来描述从 (0,0)(0, 0)(0,0) 到 (n,n)(n,n)(n,n) 的网格中,只能使用 (1,0)(1,0)(1,0).(0,1)(0,1)(0,1).(1,1)( ...

  9. Nowcoder 5477E. 弦(卡特兰数、组合数学)

    题目描述: 给定一个圆,圆上有2N个互不重叠的点.每次操作随机选择两个先前未选择过的点连一条弦,共连成N条弦,求所有弦不交的概率. 输入描述: 一行,只有一个整数N(1≤N≤10^7). 输出描述: ...

最新文章

  1. 31个好用的 Python 字符串方法,建议收藏!
  2. source insight删除保存路径为中文的project工程项目报错的解决办法
  3. 数学狂想曲(八)——核弹当量问题, Lanchester战争模型, 随机过程
  4. 会议 | CCKS 2019 全国知识图谱与语义计算大会在杭州隆重召开
  5. 数据结构知识点大汇总(八)
  6. skynet 学习笔记-netpack模块(1)
  7. 详解第一范式、第二范式、第三范式、BCNF范式
  8. uniapp app运行到手机模拟器
  9. Python生成城市热力图
  10. “值得”关注公司:我们应该向优衣库学习什么?
  11. 破解Excel的宏密码
  12. 【AirSim】Windows下搭建AirSim
  13. Race_Condition_Vulnerability
  14. 12-SpringSecurity:通过OAuth2集成Github登录
  15. 超实用BRVAH开源框架使用之添加头部尾部问题
  16. A100 Tensor核心可加速HPC
  17. Kotlin KTX 扩展库
  18. java大学教程习题答案_Java程序设计大学教程:习题解答与课程设计
  19. Message Lifecycle:Pulsar 里的信息传递究竟是什么样子
  20. 中企动力与企业同行者的那些点滴

热门文章

  1. 获取 Transaction Source
  2. spring使用@Value注解读取.properties文件时出现中文乱码问题的解决
  3. C语言学习笔记—code:blocks工具debug调试异常
  4. 【报告分享】2021抖音电商生态发展报告.pdf(附下载链接)
  5. (Object detection)目标检测从入门到精通——第一部分
  6. BERT 之后的故事
  7. 复旦邱锡鹏组最新综述:A Survey of Transformers!
  8. 深度学习与神经网络——邱锡鹏
  9. 吴恩达机器学习ex6:支持向量机
  10. Redis基础(四)——持久化