题目链接:

  http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1789

题目大意:

  求大卡特兰数。。公式如下。输入n求Sn(n<=5000)

题目思路:

  【高精度】

  Sn=Cn+1。直接压四位高精度算一遍就好。只要写高精度乘单精度,高精度除单精度。

 //
//by coolxxx
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<memory.h>
#include<time.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//#include<stdbool.h>
#include<math.h>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(a) ((a)>0?(a):(-(a)))
#define lowbit(a) (a&(-a))
#define sqr(a) ((a)*(a))
#define swap(a,b) ((a)^=(b),(b)^=(a),(a)^=(b))
#define mem(a,b) memset(a,b,sizeof(a))
#define eps (1e-8)
#define J 10000
#define mod 1000000007
#define MAX 0x7f7f7f7f
#define PI 3.14159265358979323
#define N 20004
using namespace std;
typedef long long LL;
int cas,cass;
int n,m,lll,ans;
int a[N];
void gjdchengdjd(int a[],int b)
{
int i;
for(i=;i<=a[];i++)
a[i]*=b;
for(i=;i<=a[];i++)
a[i+]+=a[i]/J,a[i]%=J;
while(a[a[]+])a[]++;
}
void gjdchudjd(int a[],int b)
{
int i;
for(i=a[];i>;i--)
a[i-]+=(a[i]%b)*J,a[i]/=b;
a[]/=b;
while(!a[a[]] && a[]>)a[]--;
}
void gjdprint(int a[])
{
int i;
printf("%d",a[a[]]);
for(i=a[]-;i;i--)
printf("%04d",a[i]);
puts("");
}
int main()
{
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
// freopen("2.txt","w",stdout);
#endif
int i,j,k;
int x,y,z;
// for(scanf("%d",&cass);cass;cass--)
// for(scanf("%d",&cas),cass=1;cass<=cas;cass++)
// while(~scanf("%s",s+1))
while(~scanf("%d",&n))
{
n++;
a[]=a[]=;
for(i=n+;i<=n+n;i++)
gjdchengdjd(a,i);
for(i=;i<=n+;i++)
gjdchudjd(a,i);
gjdprint(a);
}
return ;
}
/*
// //
*/

【高精度】NCPC 2014 C catalansqure的更多相关文章

  1. 【动态规划】【缩点】NCPC 2014 G Outing

    题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1793 题目大意: 一辆公交车,上面M个座位,N个人(M<=N<=1000) ...

  2. 【KMP】【最小表示法】NCPC 2014 H clock pictures

    题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1794 题目大意: 两个无刻度的钟面,每个上面有N根针(N<=200000),每个 ...

  3. 【图论】【宽搜】【染色】NCPC 2014 A Ades

    题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1787 题目大意: N个点M条无向边(N,M<=200000),一个节点只能有一个 ...

  4. 【模拟】NCPC 2014 E ceremony

    题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1791 题目大意: N栋大楼(N<=100000),拆除的时候有两种选择的操作,可 ...

  5. 【模拟】NCPC 2014 D Dice Game

    题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1790 题目大意: 两个人,每个人有两个骰子,每个骰子可以等概率取[a,b],问哪个人两 ...

  6. 【模拟】NCPC 2014 K Train passengers

    题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1797 题目大意: 有N个车站,火车一共可以坐M个人,每个车站下车Ai,上车Bi个人,在 ...

  7. CodeForcesGym 100502E Opening Ceremony

    Opening Ceremony Time Limit: 5000ms Memory Limit: 524288KB This problem will be judged on CodeForces ...

  8. CodeForcesGym 100502D Dice Game

    Dice Game Time Limit: 1000ms Memory Limit: 524288KB This problem will be judged on CodeForcesGym. Or ...

  9. CodeForcesGym 100502H Clock Pictures

    Clock Pictures Time Limit: 1000ms Memory Limit: 524288KB This problem will be judged on CodeForcesGy ...

随机推荐

  1. springmvc配置文件 spring-servlet

    <?xml version="1.0" encoding="UTF-8"?><!-- Bean头部 --><beans xmlns ...

  2. Asp.net中向前端输出JS的一些调用

    最近突然写ASP.NET项目,用到向前台输出JS脚本,但是以前在MVC里是通过异步或者一些方法来调用,但是ASP.net用到的很少.在网上找到一个HELPER.CS.保存一下,以后再用. using ...

  3. Date和TimeZone的关系

    java2平台为我们提供了丰富的日期时间API.如java.util.Date;java.util.calendar;java.text.DateFormat等.那么它们之间有什么关系呢? 首先,ja ...

  4. 浅谈angular框架

    最近新接触了一个js框架angular,这个框架有着诸多特性,最为核心的是:MVVM.模块化.自动化双向数据绑定.语义化标签.依赖注入,以上这些全部都是属于angular特性,虽然说它的功能十分的强大 ...

  5. Python:标准数据类型6种

    #!/usr/bin/python3 #python的基本语法和数据类型 #python3中 一行有多个语句,用分号分割(;) print("aaa") ;print(" ...

  6. SGU 157.Patience

    简单的搜索,在n>10时,要打表 code: #include<stdio.h> #include<string.h> #include<algorithm> ...

  7. Jdbc工具类(连接及释放)

    package cn.gdpe.jdbc; import java.io.File;import java.io.FileInputStream;import java.io.FileNotFound ...

  8. js 表达式与运算符 详解(上)

    表达式: 表达式是用于JavaScript脚本运行时进行计算的式子,可以包含常量.变量.运算符 <script> var r = 2 var pi = 3.14 var circle = ...

  9. Java导出Excel和CSV(简单Demo)

    Java导出Excel和CSV的简单实现,分别使用POI和JavaCSV. JavaBean public class ReportInfo { int id; String date; int nu ...

  10. javascript获取div高度

    DOM的: 获得了div的高度值 = document.getElementById("目标id").offsetHeight;