zoukankan      html  css  js  c++  java
  • A

    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. 

    InputThe 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. 
    OutputFor 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.
    
            卡兰特数 JAVA 好 max!
     1 import java.util.*;
     2 import java.math.*;
     3 public class Main 
     4 {
     5  public static BigInteger TM;
     6  public static void main(String[] args)
     7  {
     8   Scanner sc=new Scanner(System.in);
     9   while(sc.hasNext())
    10   {
    11    int n=sc.nextInt();
    12    if(n==-1)
    13        break;
    14    int a,b;
    15    TM=BigInteger.ONE;
    16    TM=TM.multiply(BigInteger.valueOf(2));
    17    if(n==1)
    18    {
    19        System.out.println(1);
    20        continue;
    21    }
    22    if(n==2)
    23    {
    24        System.out.println(2);
    25        continue;
    26    }
    27    for(int i=3;i<=n;i++)
    28    {
    29        a=4*i-2;
    30        b=i+1;
    31     TM=TM.multiply(BigInteger.valueOf(a));
    32     TM=TM.divide(BigInteger.valueOf(b));
    33    
    34    }
    35    System.out.println(TM);
    36   }
    37  }
    38 }
    View Code
  • 相关阅读:
    作业四:结对编程项目---四则运算
    作业三: 代码规范、代码复审、PSP
    自动生成四则运算题目
    源程序版本管理软件和项目管理软件的优缺点
    学习进度表
    第一周随笔
    对之前问题的回答
    结对编程——四则运算
    PSP
    代码复审
  • 原文地址:https://www.cnblogs.com/dulute/p/7272762.html
Copyright © 2011-2022 走看看