HDU 1002 A - A + B Problem II (大数问题)
原题代号:HDU 1002
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1002
原题描述:
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <iostream>
# include <fstream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <math.h>
# include <algorithm>
using namespace std;
# define pi acos(-1.0)
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define For(i,n,a) for(int i=n; i>=a; --i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define Fo(i,n,a) for(int i=n; i>a ;--i)
typedef long long LL;
typedef unsigned long long ULL; char a[+],b[+],c[+]; int main()
{
int t,sum=;
cin>>t;
while(t--)
{
if(sum)cout<<endl;
char str1[+],str2[+];
mem(a,'\0');
mem(b,'\0');
mem(c,'\0');//因为多组数据,所以清零
cin>>str1;
for(int i=sizeof(a),j=strlen(str1)-; j>=; j--,i--)
a[i]=str1[j]-;
cin>>str2;
for(int i=sizeof(b),j=strlen(str2)-; j>=; j--,i--)//将字符串放在数组末尾,并且将字符转换成ASCLL码所对应的数字
b[i]=str2[j]-;
int num=,i;
for(i=sizeof(a); i>; i--)
{
c[i]=a[i]+b[i]+num;
num=c[i]/;
c[i]%=;
}
printf("Case %d:\n%s + %s = ",++sum,str1,str2);
for(i=;i<=;i++)if(c[i])break;
for(int j=i; j<=sizeof(c); j++)
printf("%d",c[j]);//将大数表示出来
cout<<endl;
}
return ;
}
HDU 1002 A - A + B Problem II (大数问题)的更多相关文章
- HDU 1002:A + B Problem II(大数相加)
A + B Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- 杭电ACM(1002) -- A + B Problem II 大数相加 -提交通过
杭电ACM(1002)大数相加 A + B Problem II Problem DescriptionI have a very simple problem for you. Given two ...
- hdu1002 A + B Problem II(大数题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1002 A + B Problem II Time Limit: 2000/1000 MS (Java/ ...
- HDU1002 A + B Problem II 大数问题
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1002 A + B Problem II Time Limit: 2000/1000 MS (Java ...
- HDU1002 -A + B Problem II(大数a+b)
A + B Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- HDU 1023 Train Problem II 大数打表Catalan数
一个出栈有多少种顺序的问题.一般都知道是Catalan数了. 问题是这个Catalan数非常大,故此须要使用高精度计算. 并且打表会速度快非常多.打表公式要熟记: Catalan数公式 Cn=C(2n ...
- A + B Problem II 大数加法
题目描述: Input The first line of the input contains an integer T(1<=T<=20) which means the number ...
- 杭电ACM刷题(1):1002,A + B Problem II 标签: acmc语言 2017-05-07 15:35 139人阅读 评
最近忙于考试复习,没有多少可供自己安排的时间,所以我利用复习之余的空闲时间去刷刷杭电acm的题目,也当对自己编程能力的锻炼吧. Problem Description I have a very si ...
- hdu1002 A + B Problem II[大数加法]
目录 题目地址 题干 代码和解释 参考 题目地址 hdu1002 题干 代码和解释 由题意这是一个涉及到大数的加法问题.去看了一眼大数加法的方法感觉头很大,然后突然发现Java可以流氓解决大数问题,毅 ...
随机推荐
- Python基础语法之列表 元组
1 列表 列表由一系列按照特定顺序的元素组成,其中的元素可以使不同的数据类型,用[ ]来表示列表,用逗号来分割列表中的元素. 1.1 列表操作之切片 a = [1, 2, 3, 4, 5, 6, 7, ...
- vue仿阿里云后台管理(附加阿里巴巴图标使用)
先看下页面截图,在线演示地址http://aliadmin.zengjielin.top 下面有开源的代码 页面分成三大部分头部,头部菜单栏,侧边菜单栏,右侧内容栏. 现在我们担心的是怎么使用侧边栏. ...
- P1141零一迷宫
这是一道对于除了我之外其他人都十分简单的搜索题,我终于在这个夜里搞会了. 首先其问可以到达多少个点,并不是走一次可以最多经过几个点,这就解释了为什么不需要回溯,并且递归边界则是让其全部走完即可.于是便 ...
- 2、数据类型和运算符——Java数据类型
一.强类型语言和弱类型语言: 1.1 强类型语言 强类型语言是一种强制类型定义的语言,一旦某一个变量被定义类型,如果不经过强制转换,则它永远就是该数据类型了,强类型语言包括Java..net .Pyt ...
- 数据库允许空值(null),往往是悲剧的开始 (转)
数据库字段允许空值,会遇到一些问题,此处包含的一些知识点,和大家聊一聊. 数据准备: create table user ( id int, name varchar(20), index(id) ) ...
- Python 如何用列表实现栈和队列?
1.栈结构,其实就是一个后进先出的一个线性表,只能在栈顶压入或弹出元素.用列表表示栈,则向栈中压入元素,可以用列表的append()方法来实现,弹出栈顶元素可以用列表的pop()方法实现. >& ...
- SharePoint自己定义程序页面部署 不用重新启动IIS
版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/dz45693/article/details/30840255 SharePoint的部署方式默认是 ...
- 数组和datatable间的相互转换[C#]
byte[] LogMsgByte = null; DataTable dtMessageInfo = new DataTable(); //将datatable转换为数组 dtMessageInfo ...
- python查询mysql中是否存在某张表(传参)
客户端输入了表的名字,服务端判断表是否存在. 参考:https://blog.csdn.net/qq_36523839/article/details/80639297 需要导入re模块: impor ...
- c++ Socket客户端和服务端示例版本二
客户端 #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <sys/soc ...