HDU oj A + B Problem II
郁闷了就相同的代码在HDUOJ上提交就是AC在NYOJ上提交就是WA字符串处理
#include<stdio.h>
#include<string.h>
#define N 1000
char x[N],y[N];
int a[N+1];
int main()
{
int g,h=0;
scanf("%d",&g);
while(g--)
{
int k1,k2,t=0,m,n,k,i,j,l;
scanf("%s %s",x,y);
k1=strlen(x);
k2=strlen(y);
for(i=k1-1,j=k2-1,l=0;i>=0&&j>=0;i--,j--,l++)
{
m=x[i]-48;
n=y[j]-48;
k=(m+n+t)%10;
a[l]=k;
t=(m+n+t)/10;
}
while(i>=0)
{
a[l++]=x[i--]-48+t;
t=0;
}
while(j>=0)
{
a[l++]=y[j--]-48+t;
t=0;
}
printf("Case %d:\n",++h);
printf("%s + %s = ",x,y);
for(i=l-1;i>=0;i--)
printf("%d",a[i]);
printf("\n");
if(g) printf("\n");
}
return 0;
}
HDU oj A + B Problem II的更多相关文章
- 抓起根本(二)(hdu 4554 叛逆的小明 hdu 1002 A + B Problem II,数字的转化(反转),大数的加法......)
数字的反转: 就是将数字倒着存下来而已.(*^__^*) 嘻嘻…… 大致思路:将数字一位一位取出来,存在一个数组里面,然后再将其变成数字,输出. 详见代码. while (a) //将每位数字取出来, ...
- HDU 1002 A + B Problem II(高精度加法(C++/Java))
A + B Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- HDU 1002 A + B Problem II
A + B Problem II Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 16104 Accepted ...
- HDU 1002 A + B Problem II(大整数相加)
A + B Problem II Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u De ...
- HDU——1023 Train Problem II
Train Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- HDU 1002 - A + B Problem II - [高精度]
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1002 Problem DescriptionI have a very simple problem ...
- hdu 1002.A + B Problem II 解题报告
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1002 题目意思:就是大整数加法. 两年几前做的,纯粹是整理下来的. #include <stdi ...
- 大数加法~HDU 1002 A + B Problem II
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1002 题意: 数学题,A+B; 思路,这个数非常大,普通加法一定会超时,所以用大数加法.大数加法的基 ...
- HDU 1002 A + B Problem II (大数加法)
题目链接 Problem Description I have a very simple problem for you. Given two integers A and B, your job ...
随机推荐
- POJ 2945 trie树
Find the Clones Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 7704 Accepted: 2879 Descr ...
- IO流遍历文件夹下所有文件问题
import java.io.File; /** * @author 王恒 * @datetime 2017年4月20日 下午2:24:32 * @description 递归调用 * */ publ ...
- office 2010 破解
使用Rearm命令激活延迟重置Office 20101.安装Offcie 2010 安装Offcie 2010,默认30天的试用期,这里要注意,上文提供的Office 2010是零售版,所以没有序列号 ...
- 《CSS Mastery》 读书笔记 (1)
--本笔记中英混合,专业名词尽量不翻译,免得误解,如果不习惯,就不用往下看了,走好不送. 第一章 基础 人类的好奇心总是促使我们捣鼓,捣鼓是最好做有效的学习CSS的方法 In this chapter ...
- MacOS 升级后pod 出现的问题
-bash: /usr/local/bin/pod: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby: bad ...
- js弹出层的写法实例
点击后弹出界面,通过判断浏览器长宽自动设定页面宽度和登陆页面位置. <style> /*遮罩层 弹出层*/ .mask { width: 100%; background-color: r ...
- Eclipse代码自动提示(内容辅助content assist)
Eclipse中默认是输入"."后出现自动提示,用于类成员的自动提示,可是有时候我们希望它能在我们输入类的首字母后就出现自动提示,可以节省大量的输入时间(虽然按alt + /会出现 ...
- Newtonsoft.Json 处理日期格式
Newtonsoft.Json.Converters.IsoDateTimeConverter iso = new Newtonsoft.Json.Converters.IsoDateTimeConv ...
- 关于大XML文件与大节点处理(System.Xml.XmlTextReader)
近期有个任务要求处理大XML文件,其中有个存了Base64的大节点(>90M,路径已知). 这种任务只能上XmlReader,即使如此大节点的处理还是头疼了一阵…… 最初查MSDN的时候,找到了 ...
- PAT_A1034#Head of a Gang
Source: PAT A1034 Head of a Gang (30 分) Description: One way that the police finds the head of a gan ...