HDU 1047Integer Inquiry(简单大数)
来源:互联网 发布:淘宝的国行jbl靠谱吗 编辑:程序博客网 时间:2024/06/13 23:01
Integer Inquiry
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 20982 Accepted Submission(s): 5561
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>char a[1000];int b[1000];//被加的数 int c[1000];//要加的数 int main(int argc, char *argv[]){int t;scanf("%d",&t);while(t--){memset(b,0,sizeof(b));memset(c,0,sizeof(c));memset(a,0,sizeof(a));int flag=0;while(scanf("%s",a)!=EOF){if(a[0]=='0')break;int len=strlen(a),i;int l=0;for(i=len-1;i>=0;i--){c[l++]=a[i]-'0';}for(i=0;i<1000;i++){b[i]=c[i]+b[i];if(b[i]>=10){b[i]=b[i]-10;b[i+1]++; }}memset(c,0,sizeof(c));}int i;for(i=1000;i>=0;i--){if(b[i]!=0)break;}for(i;i>=0;i--){printf("%d",b[i]);}printf("\n");if(t!=0)printf("\n"); }return 0;}
阅读全文
0 0
- HDU 1047Integer Inquiry(简单大数)
- HDU 1047--Integer Inquiry 【大数】
- HDU 1047 Integer Inquiry【大数】
- hdu 1047 Integer Inquiry(大数加)
- HDU-1047 Integer Inquiry 大数相加
- HDU - 1047 - Integer Inquiry (大数高精度)
- HDU 1047 Integer Inquiry JAVA大数
- HDU ACM 1047 Integer Inquiry->大数相加
- hdu 1047 Integer Inquiry 大数加法
- HDOJ 1047 Integer Inquiry(大数)
- HDU 1047 Integer Inquiry 大数相加 string解法
- HDU 1047 Integer Inquiry 多个大数相加
- HDU 1047 Integer Inquiry 可做大数模板
- HDU-1047-Integer Inquiry(Java大数水题 && 格式恶心)
- HDU 1047 Integer Inquiry (多个大数相加)
- HDU 1047 Integer Inquiry
- HDU 1047 Integer Inquiry
- hdu 1047 Integer Inquiry
- 统计学习(监督学习)框架总结
- RPGMaker MV 插件基础02:插件的参数定义
- Lua中点号与冒号的区别
- SpringBoot(三):springboot整合mybatis(xml形式)
- 【10% free time】Tomcat学习之一:下载源码,导入eclipse
- HDU 1047Integer Inquiry(简单大数)
- java.util.concurrent介绍
- windows server 2003 serial key windows2003 sp2可用序列号大全(准版与企业版)
- leetcode148套题
- Caffe杂记(1)
- HDU 4771
- 将有序数组转换为平衡二叉搜索树
- Linux程序编译、链接、运行中的.o .a .so .ko .la文件
- 小谈 python 生成器