hdoj 1047 Integer Inquiry
来源:互联网 发布:数字图像处理算法研究 编辑:程序博客网 时间:2024/05/01 02:45
Integer Inquiry
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 14323 Accepted Submission(s): 3622
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.)
``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.
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.
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
11234567890123456789012345678901234567890123456789012345678901234567890123456789012345678900
Sample Output
370370367037037036703703703670
大数问题,就是输出有点坑:
#include<stdio.h>#include<string.h>#define MAX 500char str[MAX];int a[MAX],b[MAX];int main(){ int t,i,j,l,exist; scanf("%d",&t); while(t--) { getchar(); memset(b,0,sizeof(b)); exist=0; while(scanf("%s",str)!=EOF) { memset(a,0,sizeof(a)); if(str[0]=='0') { break; } exist++; l=strlen(str); for(i=l-1,j=0;i>=0;i--,j++) a[j]=str[i]-'0'; for(i=0;i<MAX;i++) { b[i]+=a[i]; if(b[i]>=10) { b[i]-=10; b[i+1]++; } } } if(!exist) printf("0\n"); else { for(i=MAX-1;i>=0;i--) if(b[i]) break; for(;i>=0;i--) printf("%d",b[i]); printf("\n"); } if(t>0) printf("\n"); } return 0;}
0 0
- HDOJ 1047 Integer Inquiry
- HDOJ 1047 Integer Inquiry
- HDOJ 1047 Integer Inquiry
- hdoj 1047 Integer Inquiry
- hdoj 1047 Integer Inquiry
- Integer Inquiry hdoj 1047
- hdoj 1047 Integer Inquiry
- HDOJ 1047 Integer Inquiry
- ACM HDOJ 1047 (Integer Inquiry)
- HDOJ HDU 1047 Integer Inquiry
- HDOJ 1047 Integer Inquiry(大数)
- POJ 1053 Integer Inquiry && HDOJ 1047 Integer Inquiry (大数加法)
- 大数问题之 Integer Inquiry hdoj 1047
- 【大数问题】 HDOJ 1047 Integer Inquiry
- HDOJ 1047 Integer Inquiry(多次大数相加)
- HDoj Integer Inquiry(大数)
- HDOJ Integer Inquiry (大数累加)
- HDOJ 1047 Integer Inquiry (多个大数求和)
- Spring下mybatis配置多数据源
- PYTHON-函数特性
- HDU 4641 K-string 2013年多校第4场J题 后缀自动机
- zedboard使用nfs挂载根文件系统-linux内核启动参数bootargs详解
- VGA to RGB + composite sync -converter
- hdoj 1047 Integer Inquiry
- python序列化pickle
- pomelo中的基本概念
- 两大设计模式 塑造高可读性的网页布局
- C++实现ftp客户端
- 【c语言】 求1*2*3*4*5
- hdoj 1176 免费馅饼 【DP 好题】
- Android开发如何在4.0及以上系统中自定义TitleBar
- Lambda 表达式