HDU 1023 Catalan数+高精度
链接:HDU 1023
/****************************************
* author : Grant Yuan
* time : 2014/10/19 15:51
* source : HDU 1023
* algorithm : Catalan数+高精度
* ***************************************/
import java.io.*;
import java.math.*;
import java.util.*;
public class Main{
public static void main(String args[])
{
Scanner cin=new Scanner(System.in);
BigInteger []a = new BigInteger [105];
BigInteger t;
a[0]=a[1]=BigInteger.ONE;
for(int i=2;i<=102;i++)
{
a[i]=a[i-1].multiply(BigInteger.valueOf(4*i-2)).divide(BigInteger.valueOf(i+1));
}
while(cin.hasNext()){
int n=cin.nextInt();
if(n==-1) break;
String str;
str=a[n].toString();
System.out.println(str);
}
}
}
HDU 1023 Catalan数+高精度的更多相关文章
- hdu 1023 卡特兰数+高精度
Train Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- POJ 2084 Catalan数+高精度
POJ 2084 /**************************************** * author : Grant Yuan * time : 2014/10/19 15:42 * ...
- BZOJ 2822: [AHOI2012]树屋阶梯 [Catalan数 高精度]
2822: [AHOI2012]树屋阶梯 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 779 Solved: 453[Submit][Status] ...
- Train Problem II HDU 1023 卡特兰数
Problem Description As we all know the Train Problem I, the boss of the Ignatius Train Station want ...
- HDU 1023(卡特兰数 数学)
题意是求一列连续升序的数经过一个栈之后能变成的不同顺序的数目. 开始时依然摸不着头脑,借鉴了别人的博客之后,才知道这是卡特兰数,卡特兰数的计算公式是:a( n ) = ( ( 4*n-2 ) / ...
- BZOJ 3907: 网格 [Catalan数 高精度]
3907: 网格 Time Limit: 1 Sec Memory Limit: 256 MBSubmit: 402 Solved: 180[Submit][Status][Discuss] De ...
- hdu 1023 卡特兰数《 大数》java
Train Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- HDU 1023 Train Problem II 大数打表Catalan数
一个出栈有多少种顺序的问题.一般都知道是Catalan数了. 问题是这个Catalan数非常大,故此须要使用高精度计算. 并且打表会速度快非常多.打表公式要熟记: Catalan数公式 Cn=C(2n ...
- HDU 4828 - Grids (Catalan数)
题目链接 : http://acm.hdu.edu.cn/showproblem.php?pid=4828 Catalan数的公式为 C[n+1] = C[n] * (4 * n + 2) / (n ...
随机推荐
- django 标签
django标签 {% if/for/ifequal/ifnotequal condition %} ...{{ name|first|lower}}{# interpretation:lower t ...
- 笔试算法题(43):布隆过滤器(Bloom Filter)
议题:布隆过滤器(Bloom Filter) 分析: BF由一个很长的二进制向量和一系列随机映射的函数组成,通过多个Hash函数将一个元素映射到一个Bit Array中的多个点,查询的时候仅当所有的映 ...
- squid正向代理使用
环境: Squid Cache: Version 3.5.20 操作系统: centos7.6 squid安装配置 yum install -y squid systemctl start sq ...
- mysql负载均衡
一.docker安装haproxy:docker pull haproxy 二.配置haproxy(参考url:https://zhangge.net/5125.html),vim /usr/loca ...
- js 技巧 (四)
//下载文件 function DownURL(strRemoteURL,strLocalURL) { try { var xmlHTTP=new ActiveXObject("Micr ...
- 测试第一个Oracle存储过程
存储过程语句 //简单存储过程的例子 //每调用一次打印一次hello world create or replace procedure sayhelloworld as begin dbms_ou ...
- spring+orm框架的兼容问题
Springframework和Hibernate版本对应关系 org.springframework 3.0.x对应org.hibernate4.0.x版本 org.springframework ...
- idea 修改Git密码和账号方法
IDEA修改git账号及密码的方法: 1.file->settings->passwords 2.重启IDEA 3.执行一次提交或更新 当执行提交或更新之后,idea会自动提示输入账号.密 ...
- [luoguP1944] 最长括号匹配_NOI导刊2009提高(1)
传送门 非常傻的DP. f[i]表示末尾是i的最长的字串 #include <cstdio> #include <cstring> #define N 1000001 int ...
- uva1366/LA3530
简单的矩阵上的dp 从左上角扫到右下角,dp[i][j][0] 代表在i,j处选A ,dp[i][j][1] 代表在i,j处选B. dp[i][j][0]=max(dp[i-1][j][1],dp[i ...