hdu1047 Integer Inquiry
/*
Integer Inquiry
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 15874 Accepted Submission(s): 4079 Problem Description
One 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
The 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. Output
Your program should output the sum of the VeryLongIntegers given in the input. 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. Sample Input 1 123456789012345678901234567890
123456789012345678901234567890
123456789012345678901234567890
0 Sample Output 370370367037037036703703703670 Source
East Central North America 1996
*/
#include <iostream>
#include<string.h>
#include<stdio.h>
using namespace std;
const int maxN=;
int main()
{
int n,k,i,j,len,next;
bool flag;
char ch[maxN],ans[maxN];
scanf("%d",&n);
while(n--)
{
flag=false;
memset(ans,,sizeof(ans));
for(i=; i<=maxN; i++)
{
scanf("%s",ch);
if(strcmp(ch,"")==)
break;
len=strlen(ch);
for(j=len-,k=; j>=; j--,k++)
{
next=;
ans[k]+=ch[j]-'';
while(ans[k+next]>)//must handle immediately
{
ans[k+next]-=;
ans[k++next]+=;
next+=;
}
}
}
for(j=maxN-; j>=; j--)//ans[] array can meet 0 advancely when you use strlen
{
if(ans[j]!='\0'&&!flag)
flag=true;
if(flag)
printf("%c",ans[j]+'');
}
if(!flag)//if nothing output before,we must output 0.
printf("%c",'');
printf("\n");
if(n>)
printf("\n");
}
return ;
}
hdu1047 Integer Inquiry的更多相关文章
- hdu1047 Integer Inquiry 多次大数相加
转载请注明出处:http://blog.csdn.net/u012860063 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1047 Problem ...
- (大数 string) Integer Inquiry hdu1047
Integer Inquiry Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- hdu acm-1047 Integer Inquiry(大数相加)
Integer Inquiry Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- Integer Inquiry【大数的加法举例】
Integer Inquiry Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 27730 Accepted: 10764 ...
- 424 - Integer Inquiry
Integer Inquiry One of the first users of BIT's new supercomputer was Chip Diller. He extended his ...
- Integer Inquiry
Integer Inquiry Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64u Sub ...
- hdu 1047 Integer Inquiry
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1047 Integer Inquiry Description One of the first use ...
- UVa 424 Integer Inquiry
之前杭电上也做过a + b的高精度的题,不过这道题的区别是有多组数据. 之前做的时候开了3个字符数组a,b,c,在计算的时候还要比较a,b长度,短的那个还要加'0',还设置了一个add来存放进位. 现 ...
- Poj 1503 Integer Inquiry
1.链接地址: http://poj.org/problem?id=1503 2.题目: Integer Inquiry Time Limit: 1000MS Memory Limit: 1000 ...
随机推荐
- C#从服务器下载文件到客户端源码
1.在window窗体加个button控件,双击进去
- 基于 ANSIBLE 自动化运维实践
摘要:运维这个话题很痛苦,你做任何的产品都离不开运维.不管你用什么语言.什么平台.什么技术,真正能够决定你产品成熟度的很有可能就是你运维的能力.取自 云巴 CEO 张虎在 ECUG 大会上的分享. 云 ...
- mybatis中自建的类型别名
在使用mybatis过程中经常用到类型别名,除了我们自己新建的别名外,mybatis还自带了很多类型别名和java中的类型的映射,下面先看一个自建的别名的配置 <typeAliases> ...
- B/S和C/S的区别(转)
一.什么是CS和BS结构? 1.C/S又称Client/Server或客户/服务器模式.服务器通常采用高性能的PC.工作站或小型机,并采用大型数据库系统,如Oracle.Sybase.Informix ...
- mysql 5.7.15发布
2016-09-06,mysql发布了5.7更新5.7.15,修复的bug数项目之前的版本已经大大减少,说明越来越稳定了.估计再过三四个版本,就会有很多公司开始考虑生产中使用了.
- 1、Flat UI Getting started(文档翻译)
下载链接:http://www.bootcss.com/p/flat-ui/ 一.什么是Flat UI? Flat UI 是一种漂亮的Boostrap主题.我们重新设计了它的很多组件,使得其看起来扁平 ...
- Android SDK Manager无法下载的问题
Android SDK Manager 你无法更新了. 现在这里有一个解决方案,如下. 1.启动 Android SDK Manager ,打开主界面,依次选择「Tools」.「Options...」 ...
- 触发layoutSubviews的条件
1. init初始化不会触发layoutSubviews 2. addSubview会触发layoutSubviews 3. 设置view的Frame会触发layoutSubviews,当然前提是fr ...
- IOS 支付宝-五福简单框架实现-线性滚动(UICollectionView)
猴年支付宝可算是给大家一个很好的惊喜,刺激.大家都在为敬业福而四处奔波.可是到最后也没有几个得到敬业福德,就像我.不知道大家有没有观察,五福界面的滚动是一个很好的设计.在这里,给大家带来简单的滚动实现 ...
- iOS本地数据存储(转载)
看到一篇不错的文章,推荐给大家!!! 应用沙盒 1)每个iOS应用都有自己的应用沙盒(应用沙盒就是文件系统目录),与其他文件系统隔离.应用必须待在自己的沙盒里,其他应用不能访问该沙盒 2)应用沙盒的文 ...