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 ...
随机推荐
- JavaScript基础语法及数组相关方法(1)
day51 参考:https://www.cnblogs.com/liwenzhou/p/8004649.html <!DOCTYPE html> <html lang=" ...
- 80端口被系统进程PID-4占用解决办法
今天因为工程需要就把tomcat服务器的端口改成了80了,可是一启动就出现问题了 发现报错信息是端口占用了,于是我马上就在了命令行敲入了netstat -ano查看端口占用情况 终于发现是PID为4的 ...
- Codeforces Round #439 (Div. 2) A B C
强哉qls,这场div2竟是其出的!!! A. The Artful Expedient 暴力 ^ ,判断是否出现,有大佬根据亦或的性质推出 Karen 必赢,太强啦23333333333333. # ...
- HDU 6205(尺取法)2017 ACM/ICPC Asia Regional Shenyang Online
题目链接 emmmm...思路是群里群巨聊天讲这题是用尺取法.....emmm然后就没难度了,不过时间上3000多,有点.....盗了个低配本的读入挂发现就降到2800左右, 翻了下,发现神犇Clar ...
- elasticsearch索引路径规则
Path to data on disk In prior versions of Elasticsearch, the path.data directory included a folder f ...
- Java并发工具类之同步屏障CyclicBarrier
CyclicBarrier的字面意思是可以循环使用的Barrier,它要做的事情是让一个线程到达一个Barrier的时候被阻塞,直到最后一个线程到达Barrier,屏障才会放开,所有被Barrier拦 ...
- [Swift实际操作]七、常见概念-(1).范围Range、ClosedRange和NSRange的使用实际操作
本文将为你解析区间的概念.在对字符串进行处理时,经常会使用到区间.例如获得字符串中从某个位置开始到另一个位置之间的内容. 首先导入需要使用到的框架 import Foundation 区间分为闭区间和 ...
- uiautomatorviewer 双击闪退问题解决
最近在学习app自动测试,结果在打开uiautomatorviewer查看app界面元素时,就出现了闪退的问题,找了很多很多方法,最后终于可以解决了,详情请继续往下看 首次安装adt的步骤 将下载的压 ...
- nodejs(三) --- nodejs进程与子进程
嗯,对于node的学习还远远不够,这里先做一个简单的api的记录,后续深入学习. 第一部分:nodejs中的全局对象之process进程对象 在node中的全局对象是global,相当于浏览器中的wi ...
- 搜索类网站记录 && 代理服务器
搜索类网站记录 && 代理服务器 技巧 1.使用site 我们在搜索的时候,其实不全依赖搜索引擎也是可以的, 比如我们要搜索一个 “中国” ,可以在搜索框输入 中国 site ...