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
  • 相关阅读:
    关于Manjaro+kde桌面Tim闪退的解决
    Manjaro-kde-18.1.3安装体验
    Ubuntu19.10安装
    OPPO R11刷机初体验
    Microsoft store应用商店打不开0x80131500
    提问回顾与个人总结
    OO第三单元总结
    OO第二单元总结
    软工案例分析作业
    OO第一单元总结
  • 原文地址:https://www.cnblogs.com/dulute/p/7272762.html
Copyright © 2011-2022 走看看