Train Problem II

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

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
 
出栈问题。卡特兰数。
用java解决大数是多么的方便啊!!!
第一个java程序。
 
import java.util.*;
import java.math.BigInteger; public class Main { public static void main(String[] args) {
BigInteger[] a=new BigInteger[105];
a[0]=BigInteger.valueOf(1);
a[1]=BigInteger.valueOf(1);
for(int i=2;i<=100;i++)
a[i]=BigInteger.valueOf(0);
for(int i=2;i<=100;i++)
for(int j=1;j<=i;j++)
a[i]=a[i].add(a[j-1].multiply(a[i-j]));
//System.out.println(a[10]);
Scanner in =new Scanner(System.in);
int n;
while(in.hasNext())
{
n=in.nextInt();
System.out.println(a[n]);
}
} }
j

最新文章

  1. 使用ajax技术实现txt弹出在页面上
  2. SharePoint中报表选择
  3. Nutch搜索引擎(第2期)_ Solr简介及安装
  4. PKCS10生成证书csr
  5. JDBC连接工厂类
  6. CoreLocation框架的使用
  7. 静态资源库CDN服务
  8. 浅析Linux的软中断的实现
  9. DOM对象和JQuery对象进行转换
  10. python/MySQL练习题(二)
  11. 【NOIP2012-开车旅行】
  12. python3中的type与object
  13. 常用的Tensor操作
  14. mysql表加锁、全表加锁、查看加锁、解锁
  15. Linux记录-salt分析
  16. Python编程基础[条件语句if 循环语句 for,while](二)
  17. leetcode第40题:组合总和II
  18. Jquery属性练习
  19. 论文笔记——ThiNet: A Filter Level Pruning Method for Deep Neural Network Compreesion
  20. Java8的新特性,二进制序列转十进制数字

热门文章

  1. 简单的事件处理类Event
  2. 查看表空间使用率及shrink 表空间
  3. 学习node js 之微信公众帐号接口开发 准备工作
  4. C++学习之继承中的访问控制
  5. PLY格式文件具体解释
  6. 【转】 vsftp上传文件出现553 Could not create file解决方法
  7. C - The C Answer (2nd Edition) - Exercise 1-15
  8. 【转】Android HTML5 Video视频标签自动播放与自动全屏问题解决
  9. c#用webkit内核支持html5
  10. servlet3.0 JQuary Ajax基本使用