HDU_1023_Train Problem II_卡特兰数
2024-08-27 18:29:41
Train Problem II
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7918 Accepted Submission(s):
4241
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.
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.
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.
that all the trains can get out of the railway.
Sample Input
1
2
3
10
Sample Output
1
2
5
16796
出栈问题。卡特兰数。
用java解决大数是多么的方便啊!!!
第一个java程序。
import java.util.*;
import java.math.BigInteger; public class Main { public static void main(String[] args) {
BigInteger[] a=new BigInteger[105];
a[0]=BigInteger.valueOf(1);
a[1]=BigInteger.valueOf(1);
for(int i=2;i<=100;i++)
a[i]=BigInteger.valueOf(0);
for(int i=2;i<=100;i++)
for(int j=1;j<=i;j++)
a[i]=a[i].add(a[j-1].multiply(a[i-j]));
//System.out.println(a[10]);
Scanner in =new Scanner(System.in);
int n;
while(in.hasNext())
{
n=in.nextInt();
System.out.println(a[n]);
}
} }
j
最新文章
- 使用ajax技术实现txt弹出在页面上
- SharePoint中报表选择
- Nutch搜索引擎(第2期)_ Solr简介及安装
- PKCS10生成证书csr
- JDBC连接工厂类
- CoreLocation框架的使用
- 静态资源库CDN服务
- 浅析Linux的软中断的实现
- DOM对象和JQuery对象进行转换
- python/MySQL练习题(二)
- 【NOIP2012-开车旅行】
- python3中的type与object
- 常用的Tensor操作
- mysql表加锁、全表加锁、查看加锁、解锁
- Linux记录-salt分析
- Python编程基础[条件语句if 循环语句 for,while](二)
- leetcode第40题:组合总和II
- Jquery属性练习
- 论文笔记——ThiNet: A Filter Level Pruning Method for Deep Neural Network Compreesion
- Java8的新特性,二进制序列转十进制数字