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 ...
随机推荐
- sublime-text-how-to-jump-to-file-from-find-results-using-keyboard
http://209.116.186.231/#newwindow=1&q=sublime+text+find+results+jump http://stackoverflow.com/qu ...
- MyBatis Generator XML 配置
使用反向生成器可以生成数据库表对应的实体类和mapper映射文件: 以下是具体介绍相应xml文件的配置: 附上一张配置的模板: <?xml version="1.0" enc ...
- 编写一致的符合习惯的javascript
本文转自我司的编码规范~ ==== 引言 将要叙述的这些原则旨对javascript开发的风格做指导,并非指定性的规则需绝对服从.如果需要找出一条必须遵循的原则,应该是保持代码的一致性和风格统一. 除 ...
- Class 和 MetaClass
在 OC 中,类的一个实例定义如下: /// Represents an instance of a class. struct objc_object { Class _Nonnull isa OB ...
- 屏蔽百度及其广告的部分Host
127.0.0.44 www.baidu.com127.0.0.44 cpro.baidu.com127.0.0.44 hm.baidu.com127.0.0.44 bdimg.share.baidu ...
- DIV居中的几种方法
1. body{ text-align:center; } 缺点:body内所有内容一并居中 2. .center{ position: fixed; left: 50%; } 缺点:需要设置posi ...
- LeNet - Python中的卷积神经网络
本教程将 主要面向代码, 旨在帮助您 深入学习和卷积神经网络.由于这个意图,我 不会花很多时间讨论激活功能,池层或密集/完全连接的层 - 将来会有 很多教程在PyImageSearch博客上将 ...
- Ubuntu之tar与curl操作
1,压缩备份: tar cfvj /tmp/test.tar.bz2 /tmp/test tar cfvz /tmp/test.tar.gz /tmp/test tar xfvj /tmp/tes ...
- CS231n学习笔记-图像分类笔记(上篇)
原文地址:智能单元 图像分类:所谓图像分类问题,就是已有固定的分类标签集合,然后对于输入的图像按照标签类别,将其打上标签. 下面先介绍一下一个简单的图像如何利用计算机进行分类: 例子:以下图为例,图像 ...
- 关于 IOC和spring基本配置详解
Spring 中的两个概念 IOC控制反转(也叫依赖注入DI): AOP面向切面编程: 控制反转:当某个java对象需要(依赖)另一个java对象是,不是直接创建依赖对象,而是由实现IOC的容器来创建 ...