zoukankan      html  css  js  c++  java
  • HDU_1023_Train Problem II_卡特兰数

    Train Problem II

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


    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
     
    出栈问题。卡特兰数。
    用java解决大数是多么的方便啊!!!
    第一个java程序。
     
    import java.util.*;
    import java.math.BigInteger;
    
    public class Main {
    
        public static void main(String[] args) {
            BigInteger[] a=new BigInteger[105];
            a[0]=BigInteger.valueOf(1);
            a[1]=BigInteger.valueOf(1);
            for(int i=2;i<=100;i++)
                a[i]=BigInteger.valueOf(0);
            for(int i=2;i<=100;i++)
                for(int j=1;j<=i;j++)
                    a[i]=a[i].add(a[j-1].multiply(a[i-j]));
            //System.out.println(a[10]);
            Scanner in =new Scanner(System.in);
            int n;
            while(in.hasNext())
            {
                n=in.nextInt();
                System.out.println(a[n]);
            }
        }
    
    }
    j
    View Code
  • 相关阅读:
    jsonview插件的常见使用方法整理
    有哪些可以节省chrome内存的扩展插件?
    js得到时间戳(10位数)
    html模板引擎jade的使用
    js获取url参数,操作url参数
    追加window.onload函数
    解决jquery与zepto等其它库冲突兼容的问题
    centos 搭建web平台
    简易web服务器(npm)
    js函数调用与声明 (for时注意)
  • 原文地址:https://www.cnblogs.com/jasonlixuetao/p/5531897.html
Copyright © 2011-2022 走看看