博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 1023 Train Problem II( 大数卡特兰 )
阅读量:7081 次
发布时间:2019-06-28

本文共 2517 字,大约阅读时间需要 8 分钟。


链接:

题意:裸卡特兰数,但是必须用大数做

balabala:上交高精度模板题,增加一下熟悉度


/*************************************************************************    > File Name: hdu1023.cpp    > Author:    WArobot     > Blog:      http://www.cnblogs.com/WArobot/     > Created Time: 2017年05月11日 星期四 19时25分09秒 ************************************************************************/#include
using namespace std;const int maxlen = 10000;class HP{ public: int len , s[maxlen]; HP(){ (*this) = 0; }; HP(int inte){ (*this) = inte; }; HP(const char *str){ (*this)=str; }; friend ostream & operator<<(ostream &cout,const HP &x); HP operator = (int inte); HP operator = (const char*str); HP operator * (const HP &b); HP operator - (const HP &b); HP operator / (const HP &b); int Compare (const HP &b); HP operator + (const HP &b);};ostream& operator <<(ostream & cout,const HP &x){ for(int i=x.len ; i>=1 ; i--) cout<
0;){ s[++len]=inte%10; inte/=10; }; return (*this);}HP HP::operator * (const HP &b){ int i,j; HP c; c.len = len + b.len; for(i=1;i<=c.len;i++) c.s[i] = 0; for(i=1;i<=len;i++) for(j=1;j<=b.len;j++) c.s[i+j-1] += s[i]*b.s[j]; for(i=1;i
1 && !c.s[i]) i--; c.len = i; return c;}HP HP::operator - (const HP &b){ int i,j; HP c; for(i=1,j=0;i<=len;i++){ c.s[i] = s[i] - j; if(i<=b.len) c.s[i] -= b.s[i]; if(c.s[i]<0){ j=1; c.s[i]+=10; } else j = 0; } c.len = len; while(c.len>1 && !c.s[c.len]) c.len--; return c;}int HP::Compare(const HP &y){ if(len>y.len) return 1; if(len
1)&&( s[i]==y.s[i] ) ) i--; return s[i]-y.s[i];}HP HP::operator / (const HP &b){ int i,j; HP d(0),c; for(i=len;i>0;i--){ if( !(d.len==1 && d.s[1]==0) ) { for( j = d.len; j>0;j--) d.s[j+1] = d.s[j]; ++d.len; } d.s[1] = s[i]; c.s[i] = 0; while( (j=d.Compare(b))>=0 ) { d = d-b; c.s[i]++; if(j==0) break; } } c.len = len; while( (c.len>1)&&(c.s[c.len]==0) ) c.len--; return c;}HP HP::operator + (const HP &b){ int i; HP c; c.s[1] = 0; for(i = 1; i<=len || i<=b.len || c.s[i]; i++ ){ if( i<=len ) c.s[i] += s[i]; if( i<=b.len ) c.s[i] += b.s[i]; c.s[i+1] = c.s[i]/10; c.s[i] %= 10; } c.len = i-1; if( c.len == 0 ) c.len = 1; return c;}int main(){ HP h[102]; h[0] = h[1] = 1; for(int i=2;i<=100;i++){ for(int j=0;j

转载于:https://www.cnblogs.com/WArobot/p/6842587.html

你可能感兴趣的文章
Objective-C基本数据类型
查看>>
利用localStorage本地储存js文件
查看>>
[聊一聊系列]聊一聊百度移动端首页前端速度那些事儿
查看>>
shell script编程小结——附带实例
查看>>
在 Laravel 项目中使用 Glup 之 Laravel-Elixir
查看>>
Nginx、CGI、FastCGI、PHP-CGI、PHP-FPM处理流程
查看>>
Tornado 4.3文档翻译: web框架-RequestHandler和Application 类
查看>>
版本控制总结
查看>>
数字证书、公私钥小记
查看>>
客户端开发流程
查看>>
Javascript基础之-Promise
查看>>
报名 | 清华方圆系列之大数据分析与可视化报告会将于下周举办
查看>>
了解 php.ini
查看>>
异地容灾方案解析
查看>>
深入理解Vue的生命周期
查看>>
WPF's Style BasedOn
查看>>
.NET Core实战项目之CMS 第十章 设计篇-系统开发框架设计
查看>>
.NET服务安装、卸载、启动、停止、判断是否存在
查看>>
基于深度学习的推荐系统综述 (arxiv 1707.07435) 译文第一、二章
查看>>
自定义抖动表单
查看>>