Integer Inquiry

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 9196    Accepted Submission(s): 2354

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
 
 
这道题题目的意思是要求你求大数的加法,此点没什么难度,但是为啥让无数人错的一塌糊涂勒!!还是在于他奇特的要求:
  
题目中说道的就不说了;
给出的最后一0,哪里的猫腻还是挺多的...
他直接造成下面的几组奇特数据:
当你输入
  3
 
12
1
0
 
000
00
0
 
0
output
13
 
0
 
0
 
实现代码如下....
 #include<cstdio>
#include<string>
#define maxn 2200
int main()
{
char a[maxn]={'\0'};
int sum[maxn+]={};
int inta[maxn]={};
int n;
scanf("%d",&n);
for(int k=;k<n;k++)
{
int i;
memset(sum,,sizeof sum);
while()
{
scanf("%s",a);
if(*a==''&&*(a+)=='\0')break; int len=strlen(a)-;
for( i= ; i<=len; i++ )
inta[i]=a[len-i]-'';
int c=;
for(i= ; i<maxn; i++)
{
sum[i]+=inta[i]+c ;
c=sum[i]/;
sum[i]%=;
}
memset(a,'\0',sizeof a);
memset(inta,,sizeof inta);
} if(k!=)puts(""); for(i=maxn;sum[i]==&&i>;i--); for(int j=i;j>=;j--)
printf("%d",sum[j]); puts("");
}
return ;
}

HDUOJ-----1074 Integer Inquiry的更多相关文章

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

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

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

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

  3. 424 - Integer Inquiry

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

  4. hdu1047 Integer Inquiry

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

  5. Integer Inquiry

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

  6. hdu 1047 Integer Inquiry

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

  7. UVa 424 Integer Inquiry

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

  8. Poj 1503 Integer Inquiry

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

  9. hdoj 1047 Integer Inquiry

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

  10. Problem D: Integer Inquiry

    Problem D: Integer InquiryTime Limit: 1 Sec Memory Limit: 128 MBSubmit: 41 Solved: 12[Submit][Status ...

随机推荐

  1. 《JavaScript语言精粹》笔记

    0.JavaScript的简单数据类型包括数字.字符创.布尔值(true/false).null和undefined值,其它值都是对象. 1.JavaScript只有一个数字类型,它在内部被表示为64 ...

  2. js改变iframe 的src地址

    <script> function dizhi(){ document.getElementById("aaa").src='http://www.sohu.com' ...

  3. Python实现爬虫设置代理IP和伪装成浏览器的方法(转载)

    https://www.jb51.net/article/139587.htm chrome_options = webdriver.ChromeOptions() chrome_options.ad ...

  4. ICTCLAS中的HMM人名识别

    http://www.hankcs.com/nlp/segment/ictclas-the-hmm-name-recognition.html 本文主要从代码的角度分析标注过程中的细节,理论谁都能说, ...

  5. jedis 连接 redis:Could not get a resource from the pool——我的出错原因和解决办法

    windows 下安装的,本机使用 现象:刚装好开发使用好好的, 重启电脑后就报这个错 网上的所有可能都试过,没有用. 最后,放弃所有包装,用最原始的代码进行连接测试: Jedis jedis=new ...

  6. Java try-catch-finally 返回值

    1.只有 try-catch 的情况下,如果不发生异常,则会返回  try 中的 return ; 如果发生异常,则会返回  catch 中的  return, try 中的 return 被盖掉; ...

  7. Kafka:ZK+Kafka+Spark Streaming集群环境搭建(十一)定制一个arvo格式文件发送到kafka的topic,通过Structured Streaming读取kafka的数据

    将arvo格式数据发送到kafka的topic 第一步:定制avro schema: { "type": "record", "name": ...

  8. Jquery 让contains不区分大小写

    默认的Jquery contains方法是区分大小写的,以下方法可以使contains不区分大小写(在匹配时将要匹配的元素内容全部转换成小写再进行匹配) // NEW selector jQuery. ...

  9. idea 提交代码时提示 please tell me who you are .......

  10. 从头来之【MAC下代码管理工具】

    本人使用的是一款免费的GIT管理工具SOURCETREE.在appstore下载完后安装. 先选中改变的文件拉倒上面,[COMMIT]---->[push] 如有疑问请留言