Train Problem II

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

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
 百度百科卡特兰数;
java代码;
import java.util.*;
import java.math.*; public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
BigInteger[] a=new BigInteger[110];
a[0]=new BigInteger("1");
for(int i=1;i<=100;i++)
{
int h=4*i-2;
int d=i+1;
String b="",c="";
int[] k=new int[10];
int flag=0;
while(h!=0)
{
k[flag++]=h%10;
h/=10;
}
for(int j=flag-1;j>=0;j--){
b+=k[j];
}
a[i]=a[i-1].multiply(new BigInteger(b));
flag=0;
while(d!=0)
{
k[flag++]=d%10;
d/=10;
}
for(int j=flag-1;j>=0;j--){
c+=k[j];
}
a[i]=a[i].divide(new BigInteger(c));
}
int n;
while(cin.hasNext())
{
n=cin.nextInt();
System.out.println(a[n]);
}
}
}

hdu 1023 卡特兰数+高精度的更多相关文章

  1. HDU 1023 Catalan数+高精度

    链接:HDU 1023 /**************************************** * author : Grant Yuan * time : 2014/10/19 15:5 ...

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

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

  3. Train Problem II HDU 1023 卡特兰数

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

  4. hdu 1023 卡特兰数《 大数》java

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

  5. bzoj3907 网格 & bzoj2822 [AHOI2012]树屋阶梯——卡特兰数+高精度

    题目:bzoj3907:https://www.lydsy.com/JudgeOnline/problem.php?id=3907 bzoj2822:https://www.lydsy.com/Jud ...

  6. HDU 4828 (卡特兰数+逆)

    HDU 4828 Grids 思路:能够转化为卡特兰数,先把前n个人标为0.后n个人标为1.然后去全排列,全排列的数列.假设每一个1的前面相应的0大于等于1,那么就是满足的序列,假设把0看成入栈,1看 ...

  7. BZOJ2822[AHOI2012]树屋阶梯——卡特兰数+高精度

    题目描述 暑假期间,小龙报名了一个模拟野外生存作战训练班来锻炼体魄,训练的第一个晚上,教官就给他们出了个难题.由于地上露营湿气重,必须选择在高处的树屋露营.小龙分配的树屋建立在一颗高度为N+1尺(N为 ...

  8. 【BZOJ 2822】2822: [AHOI2012]树屋阶梯(卡特兰数+高精度)

    2822: [AHOI2012]树屋阶梯 Description 暑假期间,小龙报名了一个模拟野外生存作战训练班来锻炼体魄,训练的第一个晚上,教官就给他们出了个难题.由于地上露营湿气重,必须选择在高处 ...

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

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

随机推荐

  1. 69道Java Spring 面试&笔试题

    目录 Spring 概述 依赖注入 Spring beans Spring注解 Spring数据访问 Spring面向切面编程(AOP) Spring MVC Spring 概述 1. 什么是spri ...

  2. GPS学习

    1.每一个你不满意的现在,都有一个你没有努力的曾经. //ios根据gps坐标来计算两点间的距离 //x1,y1 点1的坐标 x2,y2点2的坐标 -(double) gps2m:(double)x1 ...

  3. TreeNode动态邦定事件

    1. 显示不能用TextField,应该用StaticText 2. public void SetNodesAction(Tree t, String methodbind){ ArrayList ...

  4. centos安装apache

    查询是否已安装apache:  rpm -qa httpd 安装apache: yum install httpd -y 查询: chkconfig httpd on 启动: service http ...

  5. 自定义tableViewCell

    http://my.oschina.net/joanfen/blog/137601 效果如下图:可触发按钮事件 1.创建一个Empty Application 2.新建一个TableViewContr ...

  6. PHP中关于 basename、dirname、pathinfo 详解

    basename(url)      返回路径中的文件名部分. dirname(url)       返回路径中的目录名称部分. pathinfo(url)      返回关于文件路径的信息. bas ...

  7. ectouch第三讲之加载调用机制

    加载与调用机制:         当地址栏键入/mobile,就会加载入口文件index.php:从入口文件里面会调用EcTouch.php公共入口文件,当进入公共入口文件,会定义一些变量,然后加载公 ...

  8. Cookie机制(会话cookie和持久化cookie)在客户端保持HTTP状态信息的方案

    1. Cookie只有一个name和一个value,不同于map;购物车设计的时候需要cookie,获取购物车的cookie id,以便于将物品多次放入购物车: 2.cookie获取了其地址,并且可以 ...

  9. 20151221001 GridView 模板

    <asp:GridView ID="GridView1"                 runat="server" AllowPaging=" ...

  10. Rigidbody.position/rotation更新测试

    Rigidbody.position/rotation主要提供在下一个物理步之前更新物理位置,一般用于SweepTest这样的接口 那么测试一下会不会修改掉transform.position的值 测 ...