HDUOJ-----1074 Integer Inquiry
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
East Central North America 1996
这道题题目的意思是要求你求大数的加法,此点没什么难度,但是为啥让无数人错的一塌糊涂勒!!还是在于他奇特的要求:
题目中说道的就不说了;
给出的最后一0,哪里的猫腻还是挺多的...
他直接造成下面的几组奇特数据:
当你输入 3
12
1
0
000
00
0
0
output
13
0
0
实现代码如下....
1 #include<cstdio>
2 #include<string>
3 #define maxn 2200
4 int main()
5 {
6 char a[maxn]={' '};
7 int sum[maxn+2]={0};
8 int inta[maxn]={0};
9 int n;
10 scanf("%d",&n);
11 for(int k=0;k<n;k++)
12 {
13 int i;
14 memset(sum,0,sizeof sum);
15 while(1)
16 {
17 scanf("%s",a);
18 if(*a=='0'&&*(a+1)==' ')break;
19
20 int len=strlen(a)-1;
21 for( i=0 ; i<=len; i++ )
22 inta[i]=a[len-i]-'0';
23 int c=0;
24 for(i=0 ; i<maxn; i++)
25 {
26 sum[i]+=inta[i]+c ;
27 c=sum[i]/10;
28 sum[i]%=10;
29 }
30 memset(a,' ',sizeof a);
31 memset(inta,0,sizeof inta);
32 }
33
34 if(k!=0)puts("");
35
36 for(i=maxn;sum[i]==0&&i>0;i--);
37
38 for(int j=i;j>=0;j--)
39 printf("%d",sum[j]);
40
41 puts("");
42 }
43 return 0;
44 }
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- DevOps编程操练:用Jenkins流水线建立代码质量预警机制
- 『技术随手学』pip conda 替换清华源 Windows与Ubuntu通用
- 回滚段undo
- 『AI实践学』测试深度学习框架GPU版本是否正确安装方法:TensorFlow,PyTorch,MXNet,PaddlePaddle
- 使用Github管理Hexo博客的源文件
- oracle的userenv和nls_lang详解
- 打卡群刷题总结0925——最佳买卖股票时机含冷冻期
- 备忘:美化pymol作图1
- 宿舍(寝室)管理系统设计与实现 | 附 演示、源码地址
- Oracle字符集检查和修改
- Vue3 DOM Diff 核心算法解析
- PHP的LZF压缩扩展工具
- Python函数定义及参数详解
- 代码失而复得心塞往事 - git stash命令
- 如何通过 Shell 监控异常等待事件和活跃会话