namespace hdk{
const size_t fixsize=10000;
class StringAddition_InFix{
private:
string x="00";
inline void fixed(int size){
if(size<=x.length())return;
string res;
for(int i=1;i<=size-x.length();++i){
res.push_back('0');
}
for(int i=0;i<=x.length()-1;++i){
res.push_back(x[i]);
}
x=res;
}
inline void refixed(){
string res;bool is0=false;
res.push_back('0');
for(int i=0;i<=x.length()-1;++i){
if(x[i]!='0'||is0){
is0=true;
res.push_back(x[i]);
}
}
x=res;
}
public:
void operator =(string inx){
x.push_back('0');
for(int i=0;i<=inx.length()-1;++i){
x.push_back(inx[i]);
}
}
void operator =(long long inx){
x.clear();string ans;
int r=inx;
while(r){
ans.push_back(r%10+'0');
r/=10;
}
x.push_back('0');
for(int i=ans.size()-1;i>=0;--i){
x.push_back(ans[i]);
}
}
string it(){
string res;
for(int i=1;i<=x.length()-1;++i){
res.push_back(x[i]);
}
if(res.empty()) res="0";
return res;
}
StringAddition_InFix operator +(StringAddition_InFix a){
StringAddition_InFix ans;ans=a;
if(x.length()>ans.x.length()){
ans.fixed(x.length());
}
else fixed(ans.x.length());
for(int i=max(x.length(),ans.x.length())-1;i>=1;--i){
int np=(ans.x[i]-'0'+x[i]-'0');
if(np>=10) ans.x[i-1]+=np/10;
ans.x[i]=np%10+'0';
}
ans.refixed();refixed();
return ans;
}
StringAddition_InFix operator +(long long a){
StringAddition_InFix r;r=a;
return *this+r;
}
void operator +=(StringAddition_InFix a){
*this=*this+a;
}
void operator +=(long long a){
*this=*this+a;
}
friend ostream& operator<<(ostream& output,StringAddition_InFix& inx){
output<<inx.it()<<endl;
return output;
}
friend istream& operator>>(istream& input,StringAddition_InFix& inx){
input>>inx.x;
inx.fixed(inx.x.length()+1);
return input;
}
};
typedef StringAddition_InFix Int;
Int max(Int &la,Int &lb){
if(la.it()>lb.it()) return la;
else return lb;
}
Int min(Int &la,Int &lb){
if(la.it()<lb.it()) return lb;
else return la;
}
}

[namespace hdk] StringAddition_InFix的更多相关文章

  1. springcloud必知功能使用教程

    springcloud Spring Cloud是一系列框架的有序集合.它利用Spring Boot的开发便利性巧妙地简化了分布式系统基础设施的开发,如服务发现注册.配置中心.消息总线.负载均衡.断路 ...

  2. 理解Docker(3):Docker 使用 Linux namespace 隔离容器的运行环境

    本系列文章将介绍Docker的有关知识: (1)Docker 安装及基本用法 (2)Docker 镜像 (3)Docker 容器的隔离性 - 使用 Linux namespace 隔离容器的运行环境 ...

  3. C++ namespace

    namespace, 命名空间, 用于解决命名冲突的问题. Python中的package/module, Javascript中的object, Java中的package都具有这样的功能. 如何使 ...

  4. C++ 之namespace常见用法

    一.背景 需要使用Visual studio的C++,此篇对namespace的常用用法做个记录. 二.正文 namespace通常用来给类或者函数做个区间定义,以使编译器能准确定位到适合的类或者函数 ...

  5. using namespace std 和 using std::cin

    相较using std::cin使用using namespace std不会使得程序的效率变低,或者稳定性降低,只是这样作会将很多的名字引入程序,使得程序员使用的名字集合变小,容易引起命名冲突. 在 ...

  6. Why Namespace? - 每天5分钟玩转 OpenStack(102)

    上一节我们讨论了 Neutron 将虚拟 router 放置到 namespace 中实现了不同 subnet 之间的路由.今天探讨为什么要用 namespace 封装 router? 回顾一下前面的 ...

  7. struts2中错误There is no Action mapped for namespace [/] and action name [] associated with context path

    1 There is no Action mapped for namespace [/] and action name [] associated with context path [/Stru ...

  8. PHP 命名空间(namespace)

    PHP 命名空间(namespace) PHP 命名空间(namespace)是在PHP 5.3中加入的,如果你学过C#和Java,那命名空间就不算什么新事物. 不过在PHP当中还是有着相当重要的意义 ...

  9. AMD and CMD are dead之Why Namespace?

    缘由 当我看到_Franky兄的微博的时候: 我觉得我有必要出来详细说说KMDjs到底有什么本质上的优势了,连教主_Franky.貘吃馍香都不能理解他的好处,那么可想而知,在前端圈.或是全端圈.或是I ...

  10. 使用mvc时,在视图view中使用强类型视图,在web.config文件中添加命名空间namespace的引用不起作用,解决方法

    这是view中的model代码: @model t_user_info 这是web.config配置文件只的代码: <namespaces> <add namespace=" ...

随机推荐

  1. 数据分析应该掌握的知识及SQL技能

    一.概念及常识 1.数据分析必备的统计学知识 描述统计学 1.平均值.中位数.众数 2.方差.标准差 3.统计分布:正态分布.指数分布.二项分布.卡方分布 推论统计学 1.假设检验 2.置信区间 3. ...

  2. Prometheus 使用Python推送指标数据到Pushgateway

    使用Python推送指标数据到Pushgateway 需求描述 实践环境 Python 3.6.5 Django 3.0.6 prometheus-client 0.11.0 代码实现 !/usr/b ...

  3. Vue 根据鼠标悬停目标元素上方显示、隐藏指定元素交互实现

    Vue 根据鼠标悬停目标元素上方显示.隐藏指定元素交互实现 By:授客 QQ:1033553122 开发环境 win10 element-ui  "2.13.1" vue  &qu ...

  4. 【CI/CD】Centos7 下载安装 Jenkins

    一.Docker安装Jenkins 参考: https://www.bilibili.com/video/BV11B4y1W7eH?p=5 安装Jenkins最新稳定版镜像: [root@Centos ...

  5. 【Java】Mysql文档生成工具

    资料参考: https://blog.csdn.net/weixin_43797561/article/details/122809269 https://blog.csdn.net/qq_33177 ...

  6. 【微信小程序】03 配置项

    全局配置项: https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html 属性 类型 必填 描述 ...

  7. Jupyter Lab和Jupyter Notebook的区别

    JupyterLab与Jupyter Notebook:详细比较 简介 Jupyter Notebook是一个开源的Web应用程序,允许用户创建和共享包含实时代码.方程.可视化和解释性文本的文档.Ju ...

  8. 从.net开发做到云原生运维(三)——.net core的学习路线

    1. 前言 前面几篇文章主要讲了.net技术相关的基本概念和一些涉及的项目什么,本身也没讲太多底层的技术,这篇文章依旧不讲具体的技术,主要介绍.net技术的学习路线.学习路线也是我18年毕业的时候看到 ...

  9. 华为最高学术成果发表 —— 《Nature》正刊发表论文《Accurate medium-range global weather forecasting with 3D neural networks》

    论文<Accurate medium-range global weather forecasting with 3D neural networks>的<Nature>地址: ...

  10. LeetCode279:完全平方数——动态规划算法——python语言

    无意间看到了这么一个题: LeetCode279:完全平方数,动态规划解法超过46%,作弊解法却超过97% ============================================= ...