hdu 1023 卡特兰数《 大数》java
Train Problem II
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5372 Accepted Submission(s): 2911
The result will be very large, so you may not process it by 32-bit integers.
//package hxltom; import java.io.*;
import java.math.BigInteger;
import java.util.*; public class Main { public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub Scanner cin = new Scanner(System.in);
BigInteger dp[] = new BigInteger[];
dp[] = BigInteger.ONE;
dp[] = BigInteger.ONE;
for(int i=;i<=;i++)
{
dp[i] = dp[i-].multiply(BigInteger.valueOf(*i-)).divide(BigInteger.valueOf(i+));
}
int n;
while(cin.hasNext())
{
n = cin.nextInt();
System.out.println(dp[n]);
}
} }
另一种版本......
//package hxltom; import java.io.*;
import java.math.BigInteger;
import java.util.*; public class Main { public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub Scanner cin = new Scanner(System.in);
BigInteger dp[] = new BigInteger[101];
dp[0] = BigInteger.ONE;
dp[1] = BigInteger.ONE;
for(int i=2;i<=100;i++)
dp[i] = BigInteger.ZERO;
for(int i=2;i<=100;i++){
for(int j=0;j<i;j++)
dp[i] = dp[i].add(dp[j].multiply(dp[i-j-1]));
}
int n;
while(cin.hasNext())
{
n = cin.nextInt();
System.out.println(dp[n]);
}
} }
hdu 1023 卡特兰数《 大数》java的更多相关文章
- hdu 1023 卡特兰数+高精度
Train Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- Buy the Ticket HDU 1133 卡特兰数应用+Java大数
Problem Description The "Harry Potter and the Goblet of Fire" will be on show in the next ...
- hdu 1130,hdu 1131(卡特兰数,大数)
How Many Trees? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- 2014年百度之星程序设计大赛 - 初赛(第一轮) hdu Grids (卡特兰数 大数除法取余 扩展gcd)
题目链接 分析:打表以后就能发现时卡特兰数, 但是有除法取余. f[i] = f[i-1]*(4*i - 2)/(i+1); 看了一下网上的题解,照着题解写了下面的代码,不过还是不明白,为什么用扩展g ...
- HDU 1023(卡特兰数 数学)
题意是求一列连续升序的数经过一个栈之后能变成的不同顺序的数目. 开始时依然摸不着头脑,借鉴了别人的博客之后,才知道这是卡特兰数,卡特兰数的计算公式是:a( n ) = ( ( 4*n-2 ) / ...
- Train Problem II HDU 1023 卡特兰数
Problem Description As we all know the Train Problem I, the boss of the Ignatius Train Station want ...
- HDU 1134 卡特兰数 大数乘法除法
Problem Description This is a small but ancient game. You are supposed to write down the numbers 1, ...
- HDU 1134 Game of Connections(卡特兰数+大数模板)
题目代号:HDU 1134 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1134 Game of Connections Time Limit: 20 ...
- HDOJ/HDU 1133 Buy the Ticket(数论~卡特兰数~大数~)
Problem Description The "Harry Potter and the Goblet of Fire" will be on show in the next ...
随机推荐
- 646. Maximum Length of Pair Chain
You are given n pairs of numbers. In every pair, the first number is always smaller than the second ...
- Python面向对象(类的成员之字段)
day24 类的成员之字段 # 字段 - 普通字段,保存在对象中,执行只能通过对象访问 - 静态字段,保存在类中, 执行 可以通过对象访问 也可以通过类访问 clas ...
- hdoj1757 A Simple Math Problem(矩阵快速幂)
构造矩阵. 1,当k<=9时,直接输出: 2,当k >9时,先求原矩阵的(k-9)次幂res矩阵,在求幂的过程中对m取余.最后res矩阵再与矩阵F相乘得到矩阵ans,相乘的过程中对m取余. ...
- 二,mysql优化——sql优化基本概念
1,SQL优化的一般步骤 (1)通过show status命令了解各种SQL执行效率. (2)通过执行效率较低的SQL语句(重点select). (3)通过explain分析低效率的SQL语句的执行情 ...
- maven配置时mvn不是内部或外部问题解决
参考这里
- JMeter基础:请求参数Parameters 、Body Data的区别
使用Jmeter测试时,很多人不知道请求参数Parameters .Body Data的区别和用途,这里简单介绍下 先了解一个接口的基本概念 在客户机和服务器之间进行请求-响应时,HTTP协议中包括G ...
- JDK源码学习之 java.util.concurrent.automic包
一.概述 Java从JDK1.5开始提供了java.util.concurrent.atomic包,方便程序员在多线程环境下无锁的进行原子操作.原子变量的底层使用了处理器提供的原子指令,但是不同的CP ...
- 六:MyBatis学习总结(六)——调用存储过程
一.提出需求 查询得到男性或女性的数量, 如果传入的是0就女性否则是男性 二.准备数据库表和存储过程 create table p_user( id int primary key auto_incr ...
- Xcode10 libstdc++.6.0.9.tbd移除引起的错误
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/u ...
- Docker镜像(二)
一. 获取镜像 1.1. docker pull 镜像是运行容器的前提,也就是说没有镜像就没有办法创建容器 获取镜像的命令: docker pull 这个命令可以直接在docker Hub镜像源下载镜 ...