A + B Problem II

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 260647    Accepted Submission(s): 50397

Problem Description
I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.
 
Input
The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line consists of two positive integers, A and B. Notice that the integers are very large, that means you should not process them by using 32-bit integer. You may assume the length of each integer will not exceed 1000.
 
Output
For each test case, you should output two lines. The first line is "Case #:", # means the number of the test case. The second line is the an equation "A + B = Sum", Sum means the result of A + B. Note there are some spaces int the equation. Output a blank line between two test cases.
 
Sample Input
2
1 2
112233445566778899 998877665544332211
 
Sample Output
Case 1:
1 + 2 = 3
 
Case 2:
112233445566778899 + 998877665544332211 = 1111111111111111110
 
 

 #include<stdio.h>
#include<string.h>
#define as 1000
int main()
{
int as1[as+],as2[as+],cot=,j,t;
char shuru1[as+],shuru2[as+];
int n,i;
scanf("%d",&n);
getchar();//吸收回车符
t=n;
while(n--)
{
cot++;
scanf("%s",shuru1);
scanf("%s",shuru2);
memset(as1,,sizeof(as1));
memset(as2,,sizeof(as2));
for(i=,j=strlen(shuru1)-;j>=;j--,i++)
{
as1[i]=shuru1[j]-''; }
for(i=,j=strlen(shuru2)-;j>=;j--,i++)
{
as2[i]=shuru2[j]-'';
}
for(i=;i<as+;i++)
{
as1[i]+=as2[i];
if(as1[i]>=)//判断是否满十进一
{
as1[i+]++;
as1[i]-=;
} }
for(i=as+;(i>=)&&(as1[i]==);i--);//去掉结果前面多余的0
printf("Case %d:\n",cot);
printf("%s + %s = ",shuru1,shuru2);
if(i>=)
{
for(;i>=;i--)
printf("%d",as1[i]);
}
else
printf("");
printf("\n");
if(cot!=t)
printf("\n");//最后不要多换行
}
return ;
}
 
 

A + B Problem II---hdu1002的更多相关文章

  1. (string高精度)A + B Problem II hdu1002

    A + B Problem II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  2. 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) ...

  3. hdu1002 A + B Problem II(高精度加法) 2016-05-19 12:00 106人阅读 评论(0) 收藏

    A + B Problem II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  4. HDU1002 A + B Problem II 大数问题

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1002 A + B Problem II Time Limit: 2000/1000 MS (Java ...

  5. hdu1002 A + B Problem II(大数题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1002 A + B Problem II Time Limit: 2000/1000 MS (Java/ ...

  6. hdu1032 Train Problem II (卡特兰数)

    题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能.    (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...

  7. nyoj 623 A*B Problem II(矩阵)

    A*B Problem II 时间限制:1000 ms  |  内存限制:65535 KB 难度:1   描述 ACM的C++同学有好多作业要做,最头痛莫过于线性代数了,因为每次做到矩阵相乘的时候,大 ...

  8. HDU 1002 A + B Problem II

    A + B Problem II   Time Limit: 1000MS      Memory Limit: 65536K Total Submissions: 16104    Accepted ...

  9. A + B Problem II

    之前总是在查阅别人的文档,看着其他人的博客,自己心里总有一份冲动,想记录一下自己学习的经历.学习算法有一段时间了,于是想从算法开始自己的博客生涯O(∩_∩)O~~ 今天在网上看了一道大数相加(高精度) ...

  10. nyoj 103 A + B problem II

    点击打开链接 A+B Problem II 时间限制:3000 ms  |  内存限制:65535 KB 难度:3 描述 I have a very simple problem for you. G ...

随机推荐

  1. 逛园子,看到个练习题,小试了一把(淘宝ued的两道小题)

    闲来无事,逛园子,充充电.发现了一个挺有意思的博文,自己玩了一把. 第一题:使用 HTML+CSS 实现如图布局,border-widht 1px,一个格子大小是 60*60,hover时候边框变为橘 ...

  2. 关于Mysql不能被远程连接的问题

    1.修改mysql配置文件 注释掉   #bind_address:127.0.0.1 2.授权账户远程连接权限 grant all priveleges on '.' To 'myuser'@'%' ...

  3. Laravel 实现 Facades 功能

    使用过Laravel的同学都知道Facades 的强大,下面就让我们一起创建一个Facades 实例.如有不正确的地方,还请不吝赐教. 1. 实现Laravel的自动加载功能 首先建立目录app/li ...

  4. Palindrome(POJ 1159 DP)

      Palindrome Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 58168   Accepted: 20180 De ...

  5. 基于方法的LINQ语句

    LINQ中的查询方法有两站,一种是使用类似于SQL语句的方式,另一种则是基于方法的语句.基于方法的查询方法使用的是C#中面向对象概念的,主要的方法有: 投影:  Select | SelectMany ...

  6. 【Git】代码托管-从基本设置开始

    Git是现在比较火的一款代码托管工具,之前也有在使用GitHub,是用GitHub for windows一个图形管理的界面,如果没有这个图形控制界面的话我估计自己又要放弃了.用BASH命令来实现托管 ...

  7. 处理事件的方式:两种类的覆盖处理(自己管理,覆盖专用事件函数;自己统一管理,覆盖QWidget::Event通用函数),一种对象的处理(父控件统一管理,即安装过滤器),两种全局处理(QCoreApplication安装过滤器;覆盖notify方法)

    虽然只有一句话,但却是我自己的心得. 特别注意,bool QCoreApplication::notify(QObject *receiver, QEvent *event) 明确指明了要发送的对象, ...

  8. Linux下查看Web服务器当前的并发连接数和TCP连接状态

    对于web服务器(Nginx.Apache等)来说,并发连接数是一个比较重要的参数,下面就通过netstat命令和awk来查看web服务器的并发连接数以及TCP连接状态. $ netstat -n | ...

  9. zoj 3471 Most Powerful(状态压缩dp)

    Recently, researchers on Mars have discovered N powerful atoms. All of them are different. These ato ...

  10. VM虚拟机下CentOS 6.5配置IP地址的三种方法

    1.自动获取IP地址 虚拟机使用桥接模式,相当于连接到物理机的网络里,物理机网络有DHCP服务器自动分配IP地址. #dhclient 自动获取ip地址命令 #ifconfig 查询系统里网卡信息,i ...