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 ...
随机推荐
- A - Fox And Snake
Problem description Fox Ciel starts to learn programming. The first task is drawing a fox! However, ...
- es优化收藏
Elasticsearch常用优化 https://www.cnblogs.com/zlslch/p/6478773.html Elasticsearch 基础理论 & 配置调优 http:/ ...
- 06-联系人管理(xib应用)
ViewController.h文件中: @interface ViewController : UIViewController - (IBAction)add:(UIBarButtonItem * ...
- 5、scala数组转换
1.使用yield和函数式编程转换数组 2.算法案例:移除第一个负数之后的所有负数 1.使用yield和函数式编程转换数组 使用yield进行数组转换 结合if守卫,仅转换需要转换的元素 使用函数式编 ...
- EnforceLearning-主动强化学习
前言: 被动学习Agent由固定的策略决定其行为.主动学习Agent必须自己决定采取什么行动. 具体方法是: Agent将要学习一个包含所有行动结果概率的完整模型,而不仅仅是固定策略的模型: 接下来, ...
- C++程序设计实验安排
2016-2017第二学期C++程序设计的实验时间与地点安排如下表,请大家根据时间按时来上机实验.另外,因为原来安排在4.1的实验因为调休补周一的课,因此挪至周五.另外第4次周六的课,考虑有一些同学有 ...
- excel 打开显示安装office自定义项 安装期间出错的解决方法
用管理员身份运行EXCEL,转到COM加载项,删除对应加载项,即可. 注:上下两张图中的加载项信息不一致,仅作图示参考.
- theano和keras安装
最近在学深度学习框架,要用到keras库,keras可以搭建在tensorflow和theano上,我电脑装的是Windows,因此决定在电脑上搭建theano框架 下面回顾我的安装过程: 1.安装a ...
- C# 网页内容获取
private string GetGeneralContent(string strUrl) { string strMsg = string.Empty; try { WebRequest req ...
- Firebug全了解
Firebug是firefox下的一个扩展,能够调试所有网站语言,如Html,Css等,但FireBug最吸引人的就是javascript调试功能,使用起来非常方便,而且在各种浏览器下都能使用(IE, ...