zoukankan      html  css  js  c++  java
  • hdu 1023 卡特兰数《 大数》java

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

     另一种版本......

     1 //package hxltom;
     2 
     3 import java.io.*;
     4 import java.math.BigInteger;
     5 import java.util.*;
     6 
     7 
     8 public class Main {
     9 
    10     public static void main(String[] args) throws Exception{
    11         // TODO Auto-generated method stub
    12         
    13         Scanner cin  = new Scanner(System.in);
    14         BigInteger dp[] = new BigInteger[101];
    15         dp[0] = BigInteger.ONE;
    16         dp[1] = BigInteger.ONE;
    17         for(int i=2;i<=100;i++)
    18             dp[i] = BigInteger.ZERO;
    19         for(int i=2;i<=100;i++){
    20             for(int j=0;j<i;j++)
    21                 dp[i] = dp[i].add(dp[j].multiply(dp[i-j-1]));
    22         }
    23         int n;
    24         while(cin.hasNext())
    25         {
    26             n = cin.nextInt();    
    27             System.out.println(dp[n]);
    28         }
    29     }
    30 
    31 }
  • 相关阅读:
    Laxcus集群操作系统的分布计算模型
    LAXCUS集群操作系统能不能防止DDOS攻击
    elasticsearch安装启动过程遇到的问题
    Centos7安装snort可视化IDS平台
    网络与信息安全 -国际学术会议和期刊目录
    包的概念、导入与可见性---Go
    Encrypted Traffic Analytics 加密流量分析功能
    商务谈判技巧
    东南大学《数字图像处理》课程作业 8
    东南大学《数字图像处理》课程作业 7
  • 原文地址:https://www.cnblogs.com/tom987690183/p/3664504.html
Copyright © 2011-2022 走看看