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大数问题。
  1. //package hxltom;
  2.  
  3. import java.io.*;
  4. import java.math.BigInteger;
  5. import java.util.*;
  6.  
  7. public class Main {
  8.  
  9. public static void main(String[] args) throws Exception{
  10. // TODO Auto-generated method stub
  11.  
  12. Scanner cin = new Scanner(System.in);
  13. BigInteger dp[] = new BigInteger[];
  14. dp[] = BigInteger.ONE;
  15. dp[] = BigInteger.ONE;
  16. for(int i=;i<=;i++)
  17. {
  18. dp[i] = dp[i-].multiply(BigInteger.valueOf(*i-)).divide(BigInteger.valueOf(i+));
  19. }
  20. int n;
  21. while(cin.hasNext())
  22. {
  23. n = cin.nextInt();
  24. System.out.println(dp[n]);
  25. }
  26. }
  27.  
  28. }

另一种版本......

  1. //package hxltom;
  2.  
  3. import java.io.*;
  4. import java.math.BigInteger;
  5. import java.util.*;
  6.  
  7. public class Main {
  8.  
  9. public static void main(String[] args) throws Exception{
  10. // TODO Auto-generated method stub
  11.  
  12. Scanner cin = new Scanner(System.in);
  13. BigInteger dp[] = new BigInteger[101];
  14. dp[0] = BigInteger.ONE;
  15. dp[1] = BigInteger.ONE;
  16. for(int i=2;i<=100;i++)
  17. dp[i] = BigInteger.ZERO;
  18. for(int i=2;i<=100;i++){
  19. for(int j=0;j<i;j++)
  20. dp[i] = dp[i].add(dp[j].multiply(dp[i-j-1]));
  21. }
  22. int n;
  23. while(cin.hasNext())
  24. {
  25. n = cin.nextInt();
  26. System.out.println(dp[n]);
  27. }
  28. }
  29.  
  30. }

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. sublime-text-how-to-jump-to-file-from-find-results-using-keyboard

    http://209.116.186.231/#newwindow=1&q=sublime+text+find+results+jump http://stackoverflow.com/qu ...

  2. MyBatis Generator XML 配置

    使用反向生成器可以生成数据库表对应的实体类和mapper映射文件: 以下是具体介绍相应xml文件的配置: 附上一张配置的模板: <?xml version="1.0" enc ...

  3. 编写一致的符合习惯的javascript

    本文转自我司的编码规范~ ==== 引言 将要叙述的这些原则旨对javascript开发的风格做指导,并非指定性的规则需绝对服从.如果需要找出一条必须遵循的原则,应该是保持代码的一致性和风格统一. 除 ...

  4. Class 和 MetaClass

    在 OC 中,类的一个实例定义如下: /// Represents an instance of a class. struct objc_object { Class _Nonnull isa OB ...

  5. 屏蔽百度及其广告的部分Host

    127.0.0.44 www.baidu.com127.0.0.44 cpro.baidu.com127.0.0.44 hm.baidu.com127.0.0.44 bdimg.share.baidu ...

  6. DIV居中的几种方法

    1. body{ text-align:center; } 缺点:body内所有内容一并居中 2. .center{ position: fixed; left: 50%; } 缺点:需要设置posi ...

  7. LeNet - Python中的卷积神经网络

    本教程将  主要面向代码,  旨在帮助您 深入学习和卷积神经网络.由于这个意图,我  不会花很多时间讨论激活功能,池层或密集/完全连接的层 - 将来会有  很多教程在PyImageSearch博客上将 ...

  8. Ubuntu之tar与curl操作

    1,压缩备份: tar cfvj /tmp/test.tar.bz2  /tmp/test tar cfvz /tmp/test.tar.gz  /tmp/test tar xfvj /tmp/tes ...

  9. CS231n学习笔记-图像分类笔记(上篇)

    原文地址:智能单元 图像分类:所谓图像分类问题,就是已有固定的分类标签集合,然后对于输入的图像按照标签类别,将其打上标签. 下面先介绍一下一个简单的图像如何利用计算机进行分类: 例子:以下图为例,图像 ...

  10. 关于 IOC和spring基本配置详解

    Spring 中的两个概念 IOC控制反转(也叫依赖注入DI): AOP面向切面编程: 控制反转:当某个java对象需要(依赖)另一个java对象是,不是直接创建依赖对象,而是由实现IOC的容器来创建 ...