Train Problem II

来源:互联网 发布:淘宝aj厂货最好店 编辑:程序博客网 时间:2024/05/08 02:42

Train Problem II

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


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
12310
 

Sample Output
12516796
Hint
The result will be very large, so you may not process it by 32-bit integers.
 
import java.math.BigInteger;import java.util.Scanner;public class Main {public static void main(String[] args){int n;Scanner cin=new Scanner(System.in);BigInteger []k=new BigInteger[107];k[0]=BigInteger.valueOf(1);for(int i=1;i<=100;i++){k[i]=BigInteger.valueOf(0);for(int j=0;j<=i-1;j++){k[i]=k[i].add(k[j].multiply(k[i-j-1]));}}while (cin.hasNext()){n=cin.nextInt();System.out.println(k[n]);}}}

0 0
原创粉丝点击