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. Swift 如何像 C语言 那样接收入口参数?

    我们都知道在 Swift 语言当中不再有 main 函数了,可能了解过 C语言或者 Java 语言的同学对这一点赶到深深的不适.总之,取而代之的是 main.swift. int main(int a ...

  2. C#使用PriorityQueue

    #pragma once #include<cliext/queue> #include<cliext/vector> using namespace cliext; usin ...

  3. IntelliJ IDEA优秀插件(编程通用)

    一.IntelliJ IDEA开发 最近大部分开发IDE工具都切换到了,所以也花了点心思去找了相关的插件.这里整理的适合各种语言开发的通用插件,也排除掉IntelliJ IDEA自带的常用插件了(有些 ...

  4. Cookie、Session和Cache

    一.Cookie Cookie是保存客户端的一组数据,主要用来保存用户的个人信息,主要存放浏览器请求服务器时的请求信息,这些信息是非敏感信息.主要用于当用户访问您的系统时,应用程序可以检索以前存储的信 ...

  5. 【bzoj5180】[Baltic2016]Cities 斯坦纳树

    这题一看显然是一个裸的斯坦纳树 我们用$f[i][j]$表示经过的路径中包含了状态$i$所表示的点,且连接了$j$号点的最短路径. 显然,$f[i][j]=min\{f[i$^$k][j]+f[k][ ...

  6. AngularJS入门之动画

    AngularJS中ngAnimate模块支持动画效果,但是ngAnimate模块并未包含在AngularJS核心库中,因此需要使用ngAnimate需要在定义Module时声明对其的引用. Angu ...

  7. Maven私服架设(nexus / on windows)

    Maven私服可以用多个不同的产品可供选择,下面我们演示使用最为广泛的nexus来架设maven本地私服   Nexus的下载及安装请见官方下载页: http://www.sonatype.org/n ...

  8. Mac下使用zsh不执行/etc/profile文件

    Mac下使用了zsh会不执行/etc/profile文件,当然,如果用原始的是会执行. 转而执行的是这两个文件,每次登陆都会执行: ~/.zshrc与/etc/zshenv与/etc/zshrc 所以 ...

  9. 安装Elasticsearch5.0 部署Head插件

    部署5.0版本的ES 5.0版本的ES跟之前的版本最大的不同之处就是多了很多环境的校验,比如jdk,max-files等等. 设置内核参数 vi /etc/sysctl.conf # 增加下面的内容 ...

  10. Gen代码解读

    源代码为: package com.test19; public class Test04 { void spin(){ int i; for(i=0;i<100;i++){ ; } i = 0 ...