/*
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的更多相关文章

  1. hdu1047 Integer Inquiry 多次大数相加

    转载请注明出处:http://blog.csdn.net/u012860063 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1047 Problem ...

  2. (大数 string) Integer Inquiry hdu1047

    Integer Inquiry Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  3. hdu acm-1047 Integer Inquiry(大数相加)

    Integer Inquiry Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  4. Integer Inquiry【大数的加法举例】

    Integer Inquiry Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 27730   Accepted: 10764 ...

  5. 424 - Integer Inquiry

     Integer Inquiry  One of the first users of BIT's new supercomputer was Chip Diller. He extended his ...

  6. Integer Inquiry

    Integer Inquiry Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u Sub ...

  7. hdu 1047 Integer Inquiry

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1047 Integer Inquiry Description One of the first use ...

  8. UVa 424 Integer Inquiry

    之前杭电上也做过a + b的高精度的题,不过这道题的区别是有多组数据. 之前做的时候开了3个字符数组a,b,c,在计算的时候还要比较a,b长度,短的那个还要加'0',还设置了一个add来存放进位. 现 ...

  9. Poj 1503 Integer Inquiry

    1.链接地址: http://poj.org/problem?id=1503 2.题目: Integer Inquiry Time Limit: 1000MS   Memory Limit: 1000 ...

随机推荐

  1. 单例(C#版)

    单例: 一个类只有一个实例.巧妙利用了编程语言的一些语法规则:构造函数private, 然后提供一个public的方法返回类的一个实例:又方法和返回的类的实例都是static类型,所以只能被类所拥有, ...

  2. DevExpress GridControl功能总结

    写在前面,Dev控件已经很久了,功能也很强大,截止到现在我编写文档出来的Dev的版本已经到了14.1了,看了Demo真的很强大,效果也很好,结合自己这一个月开发,分享一下自己研究过后的经验,不让大家走 ...

  3. LeetCode127:Word Ladder II

    题目: Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) ...

  4. bzoj1146整体二分+树链剖分+树状数组

    其实也没啥好说的 用树状数组可以O(logn)的查询 套一层整体二分就可以做到O(nlngn) 最后用树链剖分让序列上树 #include<cstdio> #include<cstr ...

  5. 【转载】NodeJS、NPM安装配置步骤(windows版本)

    1.windows下的NodeJS安装是比较方便的(v0.6.0版本之后,支持windows native),只需要登陆官网(http://nodejs.org/),便可以看到首页的“INSTALL” ...

  6. File文件的Api的各种方法

    package com.immoc; import java.io.File; import java.io.IOException; public class Fileto { public sta ...

  7. php多版本管理phpenv

    曾经有试过phpbrew的童鞋应该知道有多复杂 虽然这个好久没更新了,还是可以用的-- github:phpenv/phpenv 它的原理就是处理PATH变量,将你要求的php版本的路径加到PATH的 ...

  8. [Architecture Pattern] Factory Builder

    [Architecture Pattern] Factory Builder 目的 同时提供延迟注入对象.挂载注入项目这两个功能 情景 在开发系统时,如果需要在运行时间才生成并注入对象,可以套用Fac ...

  9. [ASP.NET MVC] Model Binding With NameValueCollectionValueProvider

    [ASP.NET MVC] Model Binding With NameValueCollectionValueProvider 范例下载 范例程序代码:点此下载 问题情景 一般Web网站,都是以H ...

  10. Play常用代码片段 http://www.anool.net/?p=625

    持续更新中: (1)按照降序查询: List<Entity> entities= Entity.find("order by id desc").fetch(2);   ...