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 ...
随机推荐
- python 6:list.append(新元素)与list.insert(索引,新元素)(在列表末尾追加新元素、在索引处添加新元素)
bicycles = ['trek', 'cannondale', 'redline', 'specialized'] print(bicycles) bicycles.append("ho ...
- xx网络--工具集合
-- D:\workspace\bajie_projram\BJ.srfcb\BJ.srfcb\BJ.srfcb 8jielicai_New\App_Code\common\pg.cs---GetHt ...
- BZOJ 2084 二分+hash OR Manacher
思路: 二分+哈希 //By SiriusRen #include <cstdio> #include <cstring> #include <algorithm> ...
- android黑科技系列——微信定位聊天记录中照片的位置信息插件开发详解
一.前言 最近关于微信中,朋友之间发送原图就可能暴露你的位置信息,其实这个问题不在于微信,微信是为了更好的体验效果,才有发送原图功能,而对于拍照,发送普通图片微信后台都会过滤图片的exif信息,这样就 ...
- ★Java语法(二)——————————数据类型及装换
整数类型: 1.byte型:8位(1字节) 范围:-128~127 用法:byte x = 35 : 2.short型:16位(2字节) 范围:-32768~32767 用法:short x = ...
- selenium获取页面通过样式隐藏获取不到元素解决方案
如图更换图像这个按钮通过bottom:-30px隐藏了,通过如下代码获取不到页面元素,后台会报错 driver.findElement(By.className("js-avator-lin ...
- 【sqli-labs】 less28 GET- Error based -All you Union&Select Belong to us -String -Single quote with parenthesis(GET型基于错误的去除了Union和Select的单引号带括号字符串型注入)
这个不是基于错误的吧,看源码可以知道错误并没有输出 那就使用;%00和order by试一下 http://192.168.136.128/sqli-labs-master/Less-28/?id=1 ...
- ASP.NE 上传文件控件
protected void Button1_Click(object sender, EventArgs e) { //if (Request["id"]==null & ...
- hexo搭建博客
在使用hexo搭建个人博客的时候,修改.yml文件后出现错误:FATAL can not read a block mapping entry; a multiline key may not be ...
- CorelDRAW图片导出变色,如何解决?
很多小伙伴反映说CDR颜色导出不准确,特别是CorelDRAW X4以及之前的版本,那么CDR导出变色的问题是怎么导致的,如何解决呢,本文小编分享一些自己的心得. 一:出现问题. 比如下面这个问题,明 ...