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 ...
随机推荐
- 关于foreach中对集合执行Add或者Remove操作引发枚举值被修改异常
方法传入集合List<string> ids; 执行操作后再次循环引发异常 foreach (string id in ids) { ids.Add("a"); } 更 ...
- 重新想象 Windows 8.1 Store Apps (87) - TTS: Speak Text, Speak SSML
[源码下载] 重新想象 Windows 8.1 Store Apps (87) - TTS: Speak Text, Speak SSML 作者:webabcd 介绍重新想象 Windows 8.1 ...
- JMS学习(二)- JMS Message Model 组成介绍及消息头详解
一.前言 从本文起依次详细介绍JMS中的一些重要的概念,主要参考了官方的JMS1.1的文档,该文档很老了,是02年的,那年,JAVA还没有被Oracle收购..本文主要介绍Message及其相关概念, ...
- 数据库设计==>>MySchool
1.数据库设计的步骤 第一步:需求分析(收集信息) 第二步:绘制 E-R 图 (标示实体 ,找到实体的属性 第三步:将 E-R 图转换成数据库模型图 第四步:将数据库模型图转换成数据表 2.如何绘制 ...
- 亲们! 首次见面! 带来不适!多多见谅!--------->>Bank系统
亲们!您们好! 讲一下Bank系统的做法: 01.首先创建一个Card类 using System; using System.Collections.Generic; using System.Li ...
- windows 7文件误删shift+delete后找回
昨天要还电脑了,结果脑子一抽,某个目录还没拷贝,shift+delete了整个目录,删除到一半,完了...我的源码都在里面还没出来啊...这TMD要命啊... 赶紧搜了一把,windows文件误删恢复 ...
- webpack学习(入门基础)
webpack的学习webpack是什么?1:加载模块(将JS.sass/less.图片等作为模块来处理使用) 2:进行打包 webpack的优势?1:webpack以commonJS(JS的规范)的 ...
- 复杂表格的树形结构的添加删除行div实现
公司倒闭,换了工作,无奈选择了做外包这个差事,大公司进不去,小公司工资太低,可能也只能如此了.但无奈之举,亦不可浪费时间,多多磨练自己吧! 众所周知,做外包项目,其实就是做一些大公司的内部系统,多以管 ...
- 转:EClipse 10个最有用的快捷键
Eclipse快捷键 10个最有用的快捷键 Eclipse中10个最有用的快捷键组合 一个Eclipse骨灰级开发者总结了他认为最有用但又不太为人所知的快捷键组合.通过这些组合可以更加容易的浏览源代 ...
- sql动态insert向varchar(MAX)中写入据的问题
sql动态insert向varchar(MAX)中写入据的问题,在写入时出现列无效.后来发现,varchar要加''两个,号才可以 SET @SQL='INSERT INTO '+@TabName+' ...