Train Problem II

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

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 1130 1131 1134 1024 
 
 java大数问题。
 //package hxltom;

 import java.io.*;
import java.math.BigInteger;
import java.util.*; public class Main { public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub Scanner cin = new Scanner(System.in);
BigInteger dp[] = new BigInteger[];
dp[] = BigInteger.ONE;
dp[] = BigInteger.ONE;
for(int i=;i<=;i++)
{
dp[i] = dp[i-].multiply(BigInteger.valueOf(*i-)).divide(BigInteger.valueOf(i+));
}
int n;
while(cin.hasNext())
{
n = cin.nextInt();
System.out.println(dp[n]);
}
} }

另一种版本......

 //package hxltom;

 import java.io.*;
import java.math.BigInteger;
import java.util.*; public class Main { public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub Scanner cin = new Scanner(System.in);
BigInteger dp[] = new BigInteger[101];
dp[0] = BigInteger.ONE;
dp[1] = BigInteger.ONE;
for(int i=2;i<=100;i++)
dp[i] = BigInteger.ZERO;
for(int i=2;i<=100;i++){
for(int j=0;j<i;j++)
dp[i] = dp[i].add(dp[j].multiply(dp[i-j-1]));
}
int n;
while(cin.hasNext())
{
n = cin.nextInt();
System.out.println(dp[n]);
}
} }

hdu 1023 卡特兰数《 大数》java的更多相关文章

  1. hdu 1023 卡特兰数+高精度

    Train Problem II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  2. Buy the Ticket HDU 1133 卡特兰数应用+Java大数

    Problem Description The "Harry Potter and the Goblet of Fire" will be on show in the next ...

  3. hdu 1130,hdu 1131(卡特兰数,大数)

    How Many Trees? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  4. 2014年百度之星程序设计大赛 - 初赛(第一轮) hdu Grids (卡特兰数 大数除法取余 扩展gcd)

    题目链接 分析:打表以后就能发现时卡特兰数, 但是有除法取余. f[i] = f[i-1]*(4*i - 2)/(i+1); 看了一下网上的题解,照着题解写了下面的代码,不过还是不明白,为什么用扩展g ...

  5. HDU 1023(卡特兰数 数学)

    题意是求一列连续升序的数经过一个栈之后能变成的不同顺序的数目. 开始时依然摸不着头脑,借鉴了别人的博客之后,才知道这是卡特兰数,卡特兰数的计算公式是:a( n )  =  ( ( 4*n-2 ) / ...

  6. Train Problem II HDU 1023 卡特兰数

    Problem Description As we all know the Train Problem I, the boss of the Ignatius Train Station want ...

  7. HDU 1134 卡特兰数 大数乘法除法

    Problem Description This is a small but ancient game. You are supposed to write down the numbers 1, ...

  8. HDU 1134 Game of Connections(卡特兰数+大数模板)

    题目代号:HDU 1134 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1134 Game of Connections Time Limit: 20 ...

  9. HDOJ/HDU 1133 Buy the Ticket(数论~卡特兰数~大数~)

    Problem Description The "Harry Potter and the Goblet of Fire" will be on show in the next ...

随机推荐

  1. Android 日常总结的一些方法使用

    1. setImageResource : 更改图片的资源 2. setClickable :  设置为true时,表明控件可以点击,如果为false,就不能点击 .  注意,setOnClickLi ...

  2. Python面向对象(特殊成员)

    day25 __init__     类()自动执行     __del__     __call__     对象()  类()() 自动执行     __int__      int(对象)    ...

  3. elasticsearch 分片(Shards)的理解

    分片重要性 Es中所有数据均衡的存储在集群中各个节点的分片中,会影响ES的性能.安全和稳定性, 所以很有必要了解一下它. 分片是什么? 简单来讲就是咱们在ES中所有数据的文件块,也是数据的最小单元块, ...

  4. PHP之旅5 php的函数

    函数的结构 php的函数和其他语言的函数基本类似,和C语言比较的话主要区别在于php是一个弱语言,对类型不敏感,在函数的表现上就是,php函数没有类型定义,不像语言即使无参也要定义为void,而且不管 ...

  5. SVN图形客户端上传静态库.a文件失败

    1.原因客户端未添加静态库 2.解决办法 到项目静态库所在目录用命令行添加静态库文件 svn add ****.a 3.可能存在问题 Mac OS的自带SVN版本过低不能添加,报错如下: svn: E ...

  6. pythonweb框架Flask学习笔记02-一个简单的小程序

    #-*- coding:utf-8 -*- #导入了Flask类 这个类的实例将会是我们的WSGI应用程序 from flask import Flask #创建一个Flask类的实例 第一个参数是应 ...

  7. JS实现一个基于对象的链表

    JS实现一个基于对象的链表 /*JS实现一个基于对象的链表*/ function Node(element){ this.element = element;//节点存储的元素 this.next = ...

  8. .NET 如何隐藏Console Application的窗口

    1)创建Console Application工程 2)修改Output type 为Windows Application即可

  9. Binder AIDL中自定义类型传递的源码分析

    binder机制实现的IPC和共享内存的方式不同,它采取的是值拷贝的方式,即进程间传递的实体遵循Parcelable协议, Bp端负责向Parcel里写东西,Bn端负责从Parcel里读取还原,顺序是 ...

  10. artTemplate-优秀的前端模板引擎

    artTemplate-优秀的前端模板引擎 1.html中引入artTemplate的js文件: <script type="text/javascript" src=&qu ...