【高精度】NCPC 2014 C catalansqure
题目链接:
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的更多相关文章
- 【动态规划】【缩点】NCPC 2014 G Outing
题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1793 题目大意: 一辆公交车,上面M个座位,N个人(M<=N<=1000) ...
- 【KMP】【最小表示法】NCPC 2014 H clock pictures
题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1794 题目大意: 两个无刻度的钟面,每个上面有N根针(N<=200000),每个 ...
- 【图论】【宽搜】【染色】NCPC 2014 A Ades
题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1787 题目大意: N个点M条无向边(N,M<=200000),一个节点只能有一个 ...
- 【模拟】NCPC 2014 E ceremony
题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1791 题目大意: N栋大楼(N<=100000),拆除的时候有两种选择的操作,可 ...
- 【模拟】NCPC 2014 D Dice Game
题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1790 题目大意: 两个人,每个人有两个骰子,每个骰子可以等概率取[a,b],问哪个人两 ...
- 【模拟】NCPC 2014 K Train passengers
题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1797 题目大意: 有N个车站,火车一共可以坐M个人,每个车站下车Ai,上车Bi个人,在 ...
- CodeForcesGym 100502E Opening Ceremony
Opening Ceremony Time Limit: 5000ms Memory Limit: 524288KB This problem will be judged on CodeForces ...
- CodeForcesGym 100502D Dice Game
Dice Game Time Limit: 1000ms Memory Limit: 524288KB This problem will be judged on CodeForcesGym. Or ...
- CodeForcesGym 100502H Clock Pictures
Clock Pictures Time Limit: 1000ms Memory Limit: 524288KB This problem will be judged on CodeForcesGy ...
随机推荐
- gulp的常用api
gulp是什么? http://gulpjs.com/ 相信你会明白的! 与著名的构建工具grunt相比,有什么优势呢? 易于使用,代码优于配置 高效,不会产生过多的中间文件,减少I/O压力 易于学习 ...
- jetty服务器访问系统的域名
jetty-env.xml=><Set name="contextPath">/epps-compensation-backend</Set> 这个决 ...
- 新装的mysql,直接安装板
Windows安装MySQL解压版 http://www.cnblogs.com/xiaoit/p/3932241.html my文件 如下: [mysql]# 设置mysql客户端默认字符集defa ...
- Asp.Net 注册 邮箱激活
数据库 表的设计 State为用户状态 0为禁用 1为可用 默认为0,下面有个UserGUID,这个字段将来用于激活账户 首先你要写一个表单,验证码神马的,这个我就不写了..直接写处理的 代码在 ...
- CentOS Device eth0 does not seem to be present 解决方案
1. vi /etc/udev/rules.d/70-persistent-net.rules 记录eth1 的网卡地址 2.vi /etc/sysconfig/network-scrpits/ifc ...
- JS判断浏览器是否支持某一个CSS3属性的方法
var div = document.createElement('div'); console.log(div.style.transition); //如果支持的话, 会输出 "&quo ...
- 【转】linux 必须掌握的60个命令
Linux必学的60个命令Linux提供了大量的命令,利用它可以有效地完成大量的工作,如磁盘操作.文件存取.目录操作.进程管理.文件权限设定等.所以,在Linux系统上工作离不开使用系统提供的命令.要 ...
- .getBoundingClientRect()
.getBoundingClientRect() 该方法获得页面中某个元素的左,上,右和下分别相对浏览器视窗的位置,他返回的是一个对象,即Object,该对象有4个属性:top,left,right, ...
- Android ListView+image的使用
首先创建layout部局文件xml: <?xml version="1.0" encoding="utf-8"?> <RelativeLayo ...
- win7访问windows server 2003服务器出现未知的用户名或者错误的密码(转载)
直接放答案,感谢网友提供答案,否则自已还一直在纳闷,为什么? win7系统的安全机制限制了登陆.只要系统时间和win2003服务器的系统时间相差很多,系统就会阻止其登陆,并显示错误信息:"未 ...