BZOJ 2822 AHOI 2012 树屋阶梯 卡特兰数+高精度
来源:互联网 发布:c语言失去函数头 编辑:程序博客网 时间:2024/06/05 19:49
题目大意:高精度卡特兰数。
思路:上维基上看看,有一个模型和这个题一模一样,然后就剩下水水的高精度了。
(谁来教教我java...
CODE:
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define BASE 10000#define MAX 100010using namespace std; struct BigInt{ int num[MAX],len; BigInt(int _ = 0) { num[len = 1] = _; } BigInt operator +(const BigInt &a)const { BigInt re; re.len = max(len,a.len); int temp = 0; for(int i = 1; i <= a.len; ++i) { re.num[i] = temp + num[i] + a.num[i]; temp = re.num[i] / BASE; re.num[i] %= BASE; } if(temp) re.num[++re.len] = temp; return re; } BigInt operator *(int a)const { BigInt re; re.len = len; int temp = 0; for(int i = 1; i <= len; ++i) { re.num[i] = temp + num[i] * a; temp = re.num[i] / BASE; re.num[i] %= BASE; } while(temp) re.num[++re.len] = temp % BASE,temp /= BASE; return re; } BigInt operator /(int a)const { BigInt re; re.len = len; int temp = 0; for(int i = len; i; --i) { re.num[i] = (temp + num[i]) / a; temp = (temp + num[i]) % a * BASE; } while(!re.num[re.len]) --re.len; return re; }}; int main(){ int x; cin >> x; BigInt ans(1); for(int i = 2; i <= x; ++i) ans = ans * (4 * i - 2) / (i + 1); printf("%d",ans.num[ans.len]); for(int i = ans.len - 1; i; --i) printf("%04d",ans.num[i]); return 0;}
0 0
- BZOJ 2822 AHOI 2012 树屋阶梯 卡特兰数+高精度
- BZOJ 2822 AHOI 2012 树屋阶梯 卡特兰数 高精度
- bzoj 2822: [AHOI2012]树屋阶梯 (卡特兰数+高精度)
- BZOJ 2822 AHOI2012 树屋阶梯 卡特兰数
- 【bzoj 2822】树屋阶梯详解 卡特兰数性质
- bzoj 2822 [AHOI2012]树屋阶梯 卡特兰数
- 【BZOJ2822】【AHOI2012】树屋阶梯 卡特兰数 python高精度
- [BZOJ2822][AHOI2012]树屋阶梯(卡特兰数+组合数学+高精度)
- 卡特兰数,高精度卡特兰数
- bzoj 3907: 网格 (卡特兰数+组合数学+高精度)
- 【BZOJ】【P2822】【AHOI2012】【树屋阶梯】【Catalan数+高精度】
- 树屋阶梯(卡特兰数+高精除低精+高精乘低精)
- bzoj 1485 卡特兰数
- HDU 1023 高精度 卡特兰数
- POJ 2084 卡特兰数+高精度模板
- 【卡特兰数+高精度】HDU1023Train Problem II
- 卡特兰数(Catalan)高精度实现
- ACMSTEP 2.3.5 How Many Trees? //高精度卡特兰数
- Firefox 实用插件
- C++/CLI 托管C++之类、属性封装【7】
- CSS框模型——一切皆为框,从行框说起
- 百度定位 Android 经纬度出现4.9E-324 问题解决
- 微软百度实习面经
- BZOJ 2822 AHOI 2012 树屋阶梯 卡特兰数+高精度
- linux网络编程之TCP/IP基础(一):TCP/IP协议栈与数据报封装
- c#入门系列——基础篇
- linux网络编程之TCP/IP基础(二):利用ARP和ICMP协议解释ping命令
- linux网络编程之TCP/IP基础(三):IP数据报格式和IP地址路由
- 设计模式学习笔记 - Design Pattern
- 巧匠十进制转换成二进制,并输出二进制按位取反和逆序
- linux网络编程之TCP/IP基础(四):TCP连接的建立和断开、滑动窗口
- android 自定义控件 —— 自定义属性