hdu 1023 卡特兰数+高精度
Train Problem II
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
2
3
10
2
5
16796
The result will be very large, so you may not process it by 32-bit integers.
import java.util.*;
import java.math.*; public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
BigInteger[] a=new BigInteger[110];
a[0]=new BigInteger("1");
for(int i=1;i<=100;i++)
{
int h=4*i-2;
int d=i+1;
String b="",c="";
int[] k=new int[10];
int flag=0;
while(h!=0)
{
k[flag++]=h%10;
h/=10;
}
for(int j=flag-1;j>=0;j--){
b+=k[j];
}
a[i]=a[i-1].multiply(new BigInteger(b));
flag=0;
while(d!=0)
{
k[flag++]=d%10;
d/=10;
}
for(int j=flag-1;j>=0;j--){
c+=k[j];
}
a[i]=a[i].divide(new BigInteger(c));
}
int n;
while(cin.hasNext())
{
n=cin.nextInt();
System.out.println(a[n]);
}
}
}
hdu 1023 卡特兰数+高精度的更多相关文章
- HDU 1023 Catalan数+高精度
链接:HDU 1023 /**************************************** * author : Grant Yuan * time : 2014/10/19 15:5 ...
- 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 1023 卡特兰数《 大数》java
Train Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- bzoj3907 网格 & bzoj2822 [AHOI2012]树屋阶梯——卡特兰数+高精度
题目:bzoj3907:https://www.lydsy.com/JudgeOnline/problem.php?id=3907 bzoj2822:https://www.lydsy.com/Jud ...
- HDU 4828 (卡特兰数+逆)
HDU 4828 Grids 思路:能够转化为卡特兰数,先把前n个人标为0.后n个人标为1.然后去全排列,全排列的数列.假设每一个1的前面相应的0大于等于1,那么就是满足的序列,假设把0看成入栈,1看 ...
- BZOJ2822[AHOI2012]树屋阶梯——卡特兰数+高精度
题目描述 暑假期间,小龙报名了一个模拟野外生存作战训练班来锻炼体魄,训练的第一个晚上,教官就给他们出了个难题.由于地上露营湿气重,必须选择在高处的树屋露营.小龙分配的树屋建立在一颗高度为N+1尺(N为 ...
- 【BZOJ 2822】2822: [AHOI2012]树屋阶梯(卡特兰数+高精度)
2822: [AHOI2012]树屋阶梯 Description 暑假期间,小龙报名了一个模拟野外生存作战训练班来锻炼体魄,训练的第一个晚上,教官就给他们出了个难题.由于地上露营湿气重,必须选择在高处 ...
- hdu 1130,hdu 1131(卡特兰数,大数)
How Many Trees? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
随机推荐
- 161102、MyBatis中批量插入
方法一: <insert id="insertbatch" parameterType="java.util.List"> <selectKe ...
- HTML5与移动端Web
概述 HTML5 提供了很多新的功能,主要有: 新的 HTML 元素,例如 section, nav, header, footer, article 等 用于绘画的 Canvas 元素 用于多媒体播 ...
- JVM 指令集
指令码 助记符 说明 0x00 nop 什么都不做 0x01 aconst_null 将null推送至栈顶 0x02 iconst_m1 将int型-1推送至栈顶 0x03 iconst_0 将int ...
- vim查找/替换字符串
1.:s 命令来替换字符串. :s/vivian/sky/ 替换当前行第一个 vivian 为 sky :s/vivian/sky/g 替换当前行所有 vivian 为 sky :n,$s/vivia ...
- jquery ui 常用(二)(对话框 | 旋转器 | 工具提示框(表单) | 特效(百叶窗) )
一.添加信息的对话框 http://www.w3cschool.cc/try/tryit.php?filename=jqueryui-example-dialog-modal-form. 模态表单 ...
- javascript——web前端编程
一.弹出提示框: 连接 function disp_prompt() { var name=prompt("请输入您的名字","Bill Gates") ...
- Conditional - 编译屏蔽特性
public class Test : MonoBehaviour { void Start() { Func(); } [System.Diagnostics.Conditional("U ...
- Uva 10562 看图写树
题目链接:https://uva.onlinejudge.org/external/105/10562.pdf 紫书P170 直接在二维数组上做DFS,用的fgets函数读入数据,比较gets函数安全 ...
- 如何把drawing图像转换成wpf控件的source
此例以canvas为例 <Canvas> <Image Stretch="Fill" Width="100" Height="10 ...
- python访问mysql将返回的表转化为json
## Licensed to the Apache Software Foundation (ASF) under one or more# contributor license agreement ...