问题 B: 【高精度】简单高精度加法

时间限制: 1 Sec  内存限制: 64 MB 提交: 77  解决: 25 [提交][状态][讨论版]

题目描述

修罗王解决了计算机的内存限制问题,终于可以使用电脑进行大型的魔法运算了,他交给邪狼的第一个任务是计算两个非负整数A、B的和,其中A和B的位数在5000位以内。

输入

共两行数据,第一行为一个非负整数A,第二行为一个非负整数B,A、B的位数均在5000以内。

输出

输出一个非负数,即两数之和。

样例输入

1111111111
2222222222

样例输出

3333333333
 #include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
char a[],b[];
int tag=,c[];
int na,nb,cut;
int i,j;
int main()
{
while(cin>>a>>b){
tag=;
na=strlen(a)-;
nb=strlen(b)-;
cut=max(na,nb);
for(i=na,j=nb;i>=&&j>=;i--,j--){
tag=(a[i]-'')+(b[j]-'')+tag;
if(i==&&j==){
c[cut--]=tag;
}
if(tag>=){
c[cut--]=tag%;
tag=;
}
else{
c[cut--]=tag;
tag=;
}
}
while(i>=){
tag=(a[i]-'')+tag;
if(i==){
c[cut--]=tag;
}
if(tag>=){
c[cut--]=tag%;
tag=;
}
else{
c[cut--]=tag;
tag=;
}
i--;
}
while(j>=){
tag=(b[j]-'')+tag;
if(j==){
c[cut--]=tag;
}
if(tag>=){
c[cut--]=tag%;
tag=;
}
else{
c[cut--]=tag;
tag=;
}
j--;
}
cut=max(na,nb);
for(i=;i<=cut;i++){
cout<<c[i];
}
cout<<endl;
memset(a,,sizeof(a));
memset(b,,sizeof(b));
memset(c,,sizeof(b));
}
return ;
}

2205 Problem B的更多相关文章

  1. HDU2639Bone Collector II[01背包第k优值]

    Bone Collector II Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  2. HDU 5536 Chip Factory 【01字典树删除】

    题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=5536 Chip Factory Time Limit: 18000/9000 MS (Java/Ot ...

  3. HDU——2647Reward(DFS或差分约束)

    Reward Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Sub ...

  4. FZU 2205 据说题目很水

    2205 据说题目很水 Accept: 199    Submit: 458Time Limit: 1000 mSec    Memory Limit : 32768 KB Problem Descr ...

  5. 1199 Problem B: 大小关系

    求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...

  6. No-args constructor for class X does not exist. Register an InstanceCreator with Gson for this type to fix this problem.

    Gson解析JSON字符串时出现了下面的错误: No-args constructor for class X does not exist. Register an InstanceCreator ...

  7. C - NP-Hard Problem(二分图判定-染色法)

    C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144 ...

  8. Time Consume Problem

    I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codesch ...

  9. Programming Contest Problem Types

        Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...

随机推荐

  1. How Tomcat Works 读书笔记 八 加载器 上

    Java的类加载器 具体资料见 http://blog.csdn.net/dlf123321/article/details/39957175 http://blog.csdn.net/dlf1233 ...

  2. What is Continuous Integration?

    什么叫持续集成? 原文: https://docs.microsoft.com/en-us/azure/devops/what-is-continuous-integration ---------- ...

  3. Intent 介绍

    一.Intent的介绍 Intent的中文意思是“意图,意向”,在Android中提供了Intent机制来协助应用间的交互与通讯,Intent负责对应用中一次操作的动作.动作涉及数据.附加数据进行描述 ...

  4. Node.js nvshens图片批量下载爬虫 1.00

    //====================================================== // www.nvshens.com图片批量下载Node.js爬虫1.00 // 此程 ...

  5. android常用的一些属性说明

    android:id --- 为控件指定相应的ID android:text --- 指定控件当中显示的文字,需要注意的是,这里尽量使用strings.xml文件当中的字符串 android:griv ...

  6. node - 导包机制

    在学node js的时候,经常各种导包 let http = require('http'); 然后它的运行机制: 1. 查找当前目录下面的node_modules 2. 全局查找(首先添加到path ...

  7. Unity异常警告错误处理方法

    原地址:http://www.haogongju.net/art/2591936 1.  The AnimationClip 'cube1_anim' used by the Animation co ...

  8. 【Python 数据分析】Numpy模块

    Numpy模块可以高效的处理数据,提供数组支持.很多模块都依赖他,比如:pandas.scipy.matplotlib 安装Numpy 首先到网站:https://www.lfd.uci.edu/~g ...

  9. linux crontab执行python脚本问题

    在工作中我们经常会写一个python脚本,然后想通过定时任务去执行,这时我们会想到crontab. 通过 crontab -e去设置crontab 例如:0     0       *       * ...

  10. JSON——JavaScript 中的使用

    由于JSON非常简单,很快就风靡Web世界,并且成为ECMA标准.几乎所有编程语言都有解析JSON的库,而在JavaScript中,我们可以直接使用JSON,因为JavaScript内置了JSON的解 ...