hdu acm-1047 Integer Inquiry(大数相加)
Integer Inquiry
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 11678 Accepted Submission(s): 2936
of the first users of BIT's new supercomputer was Chip Diller. He
extended his exploration of powers of 3 to go from 0 to 333 and he
explored taking various sums of those numbers.
``This supercomputer
is great,'' remarked Chip. ``I only wish Timothy were here to see these
results.'' (Chip moved to a new apartment, once one became available on
the third floor of the Lemon Sky apartments on Third Street.)
input will consist of at most 100 lines of text, each of which contains
a single VeryLongInteger. Each VeryLongInteger will be 100 or fewer
characters in length, and will only contain digits (no VeryLongInteger
will be negative).
The final input line will contain a single zero on a line by itself.
This problem contains multiple test cases!
The
first line of a multiple input is an integer N, then a blank line
followed by N input blocks. Each input block is in the format indicated
in the problem description. There is a blank line between input blocks.
The output format consists of N output blocks. There is a blank line between output blocks.
123456789012345678901234567890
123456789012345678901234567890
123456789012345678901234567890
0
仅仅为了存一个高精度大数相加的模板
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cstring>
#include <math.h>
#include <ctime>
using namespace std;
#define maxn 32768
void add(char a[],char b[],char back[])
{
int i,j,k,up,x,y,z,l;
char *c;
if (strlen(a)>strlen(b)) l=strlen(a)+; else l=strlen(b)+;
c=(char *) malloc(l*sizeof(char));
i=strlen(a)-;
j=strlen(b)-;
k=;up=;
while(i>=||j>=)
{
if(i<) x=''; else x=a[i];
if(j<) y=''; else y=b[j];
z=x-''+y-'';
if(up) z+=;
if(z>) {up=;z%=;} else up=;
c[k++]=z+'';
i--;j--;
}
if(up) c[k++]='';
i=;
c[k]='\0';
for(k-=;k>=;k--)
back[i++]=c[k];
back[i]='\0';
} int main()
{
int n;
scanf("%d",&n);
char a[maxn]="";
while(n--)
{
char b[maxn],c[maxn];
memset(b,'\0',sizeof(b));
memset(c,'\0',sizeof(c));
memset(a,'\0',sizeof(a));
a[]='';
while()
{
scanf("%s",b);
if(b[]=='')
break;
add(a,b,c);
strcpy(a,c);
memset(b,'\0',sizeof(b));
memset(c,'\0',sizeof(c));
}
if(n==)
printf("%s\n",a);
else
printf("%s\n\n",a); }
return ;
}
hdu acm-1047 Integer Inquiry(大数相加)的更多相关文章
- HDU 1047 Integer Inquiry 大数相加 string解法
本题就是大数相加,题目都不用看了. 只是注意的就是HDU的肯爹输出,好几次presentation error了. 还有个特殊情况,就是会有空数据的输入case. #include <stdio ...
- POJ 1503 Integer Inquiry(大数相加,java)
题目 我要开始练习一些java的简单编程了^v^ import java.io.*; import java.util.*; import java.math.*; public class Main ...
- POJ 1503 Integer Inquiry(大数相加)
一.Description One of the first users of BIT's new supercomputer was Chip Diller. He extended his exp ...
- Integer Inquiry(大数相加)
Description One of the first users of BIT's new supercomputer was Chip Diller. He extended his explo ...
- hdu 1047 Integer Inquiry
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1047 Integer Inquiry Description One of the first use ...
- hdoj 1047 Integer Inquiry
Integer Inquiry Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- Integer Inquiry 大数加法
Integer Inquiry 1 import java.util.*; 2 import java.math.*; 3 import java.io.*; 4 import java.text.* ...
- hdu 1047 Integer Inquiry(大数)
题意:整数大数加法 思路:大数模板 #include<iostream> #include<stdio.h> #include<stdlib.h> #include ...
- hdu 1047 Integer Inquiry(高精度数)
Problem Description Oneof the first users of BIT's new supercomputer was Chip Diller. He extended hi ...
随机推荐
- Web开发必知的八种隔离级别
ACID性质是数据库理论中的奠基石,它定义了一个理论上可靠数据库所必须具备的四个性质:原子性,一致性,隔离性和持久性.虽然这四个性质都很重要,但是隔离性最为灵活.大部分数据库都提供了一些可供选择的隔离 ...
- js/jstl/el的区别
JavaScript 学习的路径:http://www.w3school.com.cn/js/js_intro.asp 是世界上最流行的编程语言. 这门语言可用于 HTML 和 web,更可广泛用于服 ...
- 触摸屏测试:Tslib
触摸屏测试:Tslib(配置了一天,心累) 总结:网上有许多关于tslib的步骤/错误总结,所以这里只是提几个我觉得比较棘手的问题: 1,我明明给arm-linux-gcc配置了环境变量,为什么还是提 ...
- lucene历史版本地址
http://archive.apache.org/dist/lucene/java/
- dp与px转换
名词 解释 Px (Pixel像素) 不同设备显示效果相同.这里的“相同”是指像素数不会变,比如指定UI长度是100px,那不管分辨率是多少UI长度都是100px.也正是因为如此才造成了UI在小分辨率 ...
- Eclipse各种配置
1.配置工作空间编码 Window -- Preferences-- Genereal -- Workspace (Text file encoding -- orther -- utf-8) 2 ...
- JavaWeb 学习006-4个页面,5条sql语句(添加、查看、修改、删除)
今天遇到的问题: 1. 在list页面上添加信息时候,跳转到doAdd页面后,点击保存按钮,能够跳转回list页面,但是新增的信息不能显示出来,就像是没有执行添加操作一样. 这是什么问题? ①是不是到 ...
- iOS实现类似于歌词进度效果
先看效果 这里关键的地方在于镂空文字的实现,可以用UILabel的drawRect方法. .h文件 @interface HollowLabel : UILabel @end .m文件 @interf ...
- HTML5实现摇一摇
一.原理: 利用devicemotion获取移动速度,得到device移动时相对之前某个时间的差值比 二.效果图: 三.源码: //先判断设备是否支持HTML5摇一摇功能 if (window.Dev ...
- 解决jquery-ui-autocomplete选择列表被Bootstrap模态窗遮挡的问题
最近在一个ASP.NET MVC5项目中使用Bootstrap的模态窗(弹出层)来让用户填写内容,其中的一个编辑框提供了自动完成功能,用jQuery UI Autocomplete来实现. 因为我是W ...