Integer Inquiry 大数相加
来源:互联网 发布:淘宝怎么看淘龄 编辑:程序博客网 时间:2024/05/21 14:56
点击打开链接
Integer Inquiry
Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 26112 Accepted: 10141
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.
Sample Input
1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678900
Sample Output
370370367037037036703703703670
Source
East Central North America 1996
如果让我单独做的话,做不出来,借鉴同学的思想才做出来。此题使我收益颇大。
#include<stdio.h>#include<string>#include<algorithm>#include<iostream>using namespace std;int main(){ int x[1007]={0}; int count=0,c; string z; while(cin>>z&&z!="0") { reverse(z.begin(),z.end()); if(count<z.size())count=z.size(); for(int a=0;a<z.size();a++) x[a]+=z[a]-'0'; } count+=10; for(int b=0;b<count;b++) { c=x[b]/10; x[b]%=10; x[b+1]+=c; } while(!x[count])count--; for(int c=count;c>=0;c--) printf("%d",x[c]); printf("\n"); return 0;}
- Integer Inquiry 大数相加
- Integer Inquiry(大数相加)
- Integer Inquiry 大数相加
- POJ 1503 Integer Inquiry【大数相加 java】
- PKU-1503 Integer Inquiry(模拟大数相加)
- zoj_1292 Integer Inquiry(大数相加)
- POJ 1503 Integer Inquiry(大数相加)
- HDU-1047 Integer Inquiry 大数相加
- hdu1047 Integer Inquiry 多次大数相加
- HDU ACM 1047 Integer Inquiry->大数相加
- HDOJ 1047 Integer Inquiry(多次大数相加)
- POJ 1503 Integer Inquiry 简单大数相加
- poj1503 Integer Inquiry (大数相加)
- hust Integer Inquiry(字符串,大数相加)
- UVA 424 - Integer Inquiry (大数相加问题)
- poj 1503 Integer Inquiry(多个大数相加)
- HDU 1047 Integer Inquiry 大数相加 string解法
- HDU 1047 Integer Inquiry 多个大数相加
- 线段树入门
- USACO 1.2.2 Transformations(模拟)
- lcd 帧设备驱动(一)
- N皇后问题
- 之前的一些sql
- Integer Inquiry 大数相加
- 指定日前的前后n天问题
- oracle中重命名列名和表名
- oracle安装过程中出现ORA-12705和ORA-01264错误解决方法
- BlockingQueue
- Android系统手机端抓包方法---张子芳
- Linux 平台下 RMAN 全备 和 增量备份 shell 脚本
- python多线程采集原理测试
- AWK中使用函数