poj 1503
来源:互联网 发布:女权癌 知乎 编辑:程序博客网 时间:2024/06/01 17:09
Integer Inquiry
Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 34666 Accepted: 13499
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
一道大数相加的变形题,比较简单
#include<iostream>#include<string>#include<string.h>using namespace std;#include<algorithm> #include<math.h>int a[110];int main(){string s;int index=0;memset(a,0,sizeof(a));while(cin>>s,s!="0"){for(int i=s.size()-1;i>=0;i--){a[index]+=s[i]-'0';index++;}index=0;}int c=0;for(int i=0;i<110;i++){a[i]+=c;c=a[i]/10;a[i]%=10;}int flag=0;for(int i=109;i>=0;i--){if(a[i]&&!flag){cout<<a[i];flag=1;}else if(flag)cout<<a[i];}cout<<endl;return 0;}
阅读全文
0 0
- poj 1503
- POJ-1503
- POJ 1503
- poj 1503
- poj - 1503
- poj 1503
- poj 1503
- POJ 1503
- poj 1503
- POJ 1503 Integer Inquiry
- poj 1503 大数相加
- poj 1503 Integer Inquiry
- POJ 1503 Integer Inquiry
- poj 1503 Integer Inquiry
- POJ 1503 Integer Inquiry
- POJ 1503 Integer Inquiry
- POJ---1503 Integer Inquiry
- poj 1503 Integer Inquiry
- JDK8中Lambda表达式的使用
- Vuforia Tools
- 为什么远程连接数据库速度会很慢?
- 第二篇 HTML 常用元素及属性值
- 全局变量的细节问题(1-1-3)
- poj 1503
- 【网络流24题】深海机器人(最大费用流)
- Unity UI系统-NGUI-AtlasMaker
- Django爬过的坑系列 --- 在PyCharm内链接 MySQL数据库
- 5.[easy]Plus one
- python+selenium自动化软件测试(第10章):测试驱动TDD
- HTextView:非常炫酷的 TextView 效果
- Spark Streaming基础学习【二】数值累加
- 使用IDEA+Java+Tomcat搭建远端服务器