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 ...
随机推荐
- Visual Studio《加载此属性页时出错》的解决办法
打开aspx页面时不能切换到设计视图,vs 2008工具箱中无控件.打开vs 2008的工具>选项>HTML设计器时提示:加载此属性页时出错 有时还会有其它错误提示,比如打开一个Windo ...
- nginx配合modsecurity实现WAF功能
一.准备工作 系统:centos 7.2 64位.nginx1.10.2, modsecurity2.9.1 owasp3.0 1.nginx:http://nginx.org/download/ng ...
- DShow实现一个avi视频的播放(含有个人解释和注释)
此项目为win32下的控制台C++代码(别忘记配置DShow库) // movie_test.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" ...
- udid替代方案
转自http://www.cnblogs.com/zhulin/archive/2012/03/26/2417860.html UDID替代方案 背景: 大多数应用都会用到苹果设备的UDID号,U ...
- 为什么要选择Sublime Text3?
为什么要选择Sublime Text3? Sublime Text3 自动保存,打开图片 跨平台启动快!!!!多行游标,太好用. 插件,简直选不过来. 代码片段 VIM兼容模式 菜单栏基础功能介绍 F ...
- ASP.NET MVC 微信公共平台开发之 微信接入
ASP.NET MVC 接入微信公共平台 申请微信公共账号 既然要接入微信公共平台,微信公共号是必须的(当然如果只是测试的话也可以申请微信公共平台接口测试账号),来这里微信公共平台 申请微信公共号(注 ...
- c++类的定义《一》
最近好忙,一来要在店里看店,二来朋友办结婚酒,搞的我这几天好疲惫啊···博客又有好几天没提笔了. 下午简单看了下书,看到了类的部分,自己动手练习了一下 笔记:1.类是数据类型 / 它的变童就是对象 ...
- 3.0之后在LinearLayout里增加分割线
android:divider="@drawable/shape"<!--分割线图片--> android:showDividers="middle|begi ...
- OC--代理模式
一,代理设计模式的场合: 当对象A发生了一些行为,想告知对象B (让对象B成为对象A的代理对象) 对象B想监听对象A的一些行为 (让对象B成为对象A的代理对象) 当对象A无法处理某些行为的时候,想让对 ...
- IOS NSThread
任何一个 iOS 应用程序都是由一个或者多个线程构成的.无论你是否使用了多线程编程技术,至少有 1 个 线程被创建.多线程就是为了提高引用程序的工作效率!避免阻塞主线程!当我们没有用任何多线程技术的话 ...