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
  • 相关阅读:
    最短路径问题
    这是我的第一篇博客
    Time Series Anomaly Detection
    R-CNN, Fast R-CNN, Faster R-CNN, Mask R-CNN
    database 学习
    AWS Cloud Practioner 官方课程笔记
    Cassandra commands
    go 语言学习
    [Udemy] ES 7 and Elastic Stack
    第9章 内联函数
  • 原文地址:https://www.cnblogs.com/dulute/p/7272762.html
Copyright © 2011-2022 走看看