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. flask之flask_sqlalchemy

    一. 介绍 SQLAlchemy是一个基于Python实现的ORM框架.该框架建立在 DB API之上,使用关系对象映射进行数据库操作,简言之便是:将类和对象转换成SQL,然后使用数据API执行SQL ...

  2. poj3070矩阵快速幂求斐波那契数列

      Fibonacci Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13172   Accepted: 9368 Desc ...

  3. 听补天漏洞审核专家实战讲解XXE漏洞

    对于将“挖洞”作为施展自身才干.展现自身价值方式的白 帽 子来说,听漏洞审核专家讲如何挖掘并验证漏洞,绝对不失为一种快速的成长方式! XXE Injection(XML External Entity ...

  4. [JavaScript] 判断设备类型,加载相应css

    $(document).ready(function () { var browser = { versions: function () { var u = navigator.userAgent, ...

  5. shell while-ssh

    Linux shell脚本使用while循环执行ssh的注意事项 浏览:86次 出处信息 如果要使用ssh批量登录到其它系统上操作时,我们会采用循环的方式去处理,那么这里存在一个巨大坑,你必须要小心了 ...

  6. jvm(1)类加载(一)(加载过程,双亲加载)

    JVM类加载器机制与类加载过程 jvm虚拟机的种类: Hotspot(Oracle)(基本上都是在说这个) J9, JikesRVM(IBM) Zulu, Zing (Azul) Launcher是一 ...

  7. 解决git commit 遇到datached HEAD问题

    git detached HEAD 你可以认为 HEAD(大写)是”current branch”(当下的分支).当你用git checkout切换分支的时候,HEAD 修订版本重新指向新的分支. 有 ...

  8. Requests库入门实例

    爬虫入门5个实例 实例1:京东商品页面的爬取 import requests def getHTMLText(url): try: r = requests.get(url,timeout = 30) ...

  9. POJ 1125

    #include<iostream> #include<stdio.h> #define MAXN 102 #define inf 100000000 using namesp ...

  10. J05-Java IO流总结五 《 BufferedInputStream和BufferedOutputStream 》

    1. 概念简介 BufferedInputStream和BufferedOutputStream是带缓冲区的字节输入输出处理流.它们本身并不具有IO流的读取与写入功能,只是在别的流(节点流或其他处理流 ...