Problem D: Integer Inquiry
Problem D: Integer Inquiry
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 41 Solved: 12
[Submit][Status][Web Board]
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.
Sample Input
123456789012345678901234567890
123456789012345678901234567890
123456789012345678901234567890
0
Sample Output
370370367037037036703703703670
my answer:
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<string>
using namespace std;
int main()
{
char a[];
char b[];
memset(a,'',sizeof(a));
memset(b,'',sizeof(b)); while(cin>>b)
{
int sum[]={};
int t2=strlen(b),p=t2;
b[t2]='';
for(int i=;t2->=;i--,t2--){
b[i]=b[t2-];
b[t2-]='';
}
while(scanf("%s",a)&&strcmp(a,""))
{
int t1=strlen(a),q=t1;
a[t1]='';
for(int i=;t1->=;i--,t1--){
a[i]=a[t1-];
a[t1-]='';
}
for(int j=;j>=;j--)
b[j]=(b[j]-'')+(a[j]-'')+'';
for(int i=;i>=;i--)
sum[i]=b[i]-''; for(int j=;j>=;j--){
sum[j-]+=sum[j]/;
sum[j]=sum[j]%;
}
}
memset(a,'',sizeof(a));
memset(b,'',sizeof(b));
int start=;
for(int k=;k<=;k++)
if(sum[k]==)
start++;
else
break;
for(int k=start;k<=;k++)
cout<<sum[k];
cout<<endl;
}
return ;
}
Problem D: Integer Inquiry的更多相关文章
- hdu acm-1047 Integer Inquiry(大数相加)
Integer Inquiry Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- Integer Inquiry【大数的加法举例】
Integer Inquiry Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 27730 Accepted: 10764 ...
- hdu1047 Integer Inquiry
/* Integer Inquiry Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- hdu 1047 Integer Inquiry
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1047 Integer Inquiry Description One of the first use ...
- Poj 1503 Integer Inquiry
1.链接地址: http://poj.org/problem?id=1503 2.题目: Integer Inquiry Time Limit: 1000MS Memory Limit: 1000 ...
- hdoj 1047 Integer Inquiry
Integer Inquiry Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- (大数 string) Integer Inquiry hdu1047
Integer Inquiry Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- HDUOJ-----1074 Integer Inquiry
Integer Inquiry Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- 424 - Integer Inquiry
Integer Inquiry One of the first users of BIT's new supercomputer was Chip Diller. He extended his ...
随机推荐
- chrome调试ajax
network可以查看ajax的信息.非常的实用.
- HDU 5972 Regular Number(ShiftAnd+读入优化)
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5972 [题目大意] 给出一个字符串,找出其中所有的符合特定模式的子串位置,符合特定模式是指,该子串 ...
- uestc 10 In Galgame We Trust
题意:求最长的合法括号序列 解:栈+分类讨论 now表示已经算出的序列,且此序列与现在扫描的序列可能能够连接,tmp表示现在扫描到的序列长度 左括号入栈 右括号:1.栈空时:统计当前总长 并且将栈,n ...
- 解决mac插入U盘不显示标识问题
有时候,我们在使用U盘的时候,如果未能正常退出U盘,下次插入U盘可能会不显示U盘. 解决办法如下,打开Finder-->偏好设置,设置 成功解决问题.
- CSS样式表初始化代码
CSS为什么要初始化?建站老手都知道,这是为了考虑到浏览器的兼容问题,其实不同浏览器对有些标签的默认值是不同的,如果没对CSS初始化往往会出现浏览器之间的页面差异.当然,初始化样式会对SEO有一定的影 ...
- Xposed学习
刚接触,不是太懂,就昨天root荣耀6就花了一天时间,其实root早就ok,只是因为Xposed框架总是提示红色警告,以为不好用,后来试了几次发现,跟手机也有很大关系,有的不能很好的支持框架,有的模块 ...
- [C#技术参考]在PictureBox 中绘图防止闪烁的办法
开篇之前说点别的,马上年终了,好希望年终奖大大的,但是好像这次项目的展示很重要,所以这几天绷得比较近,但是真的没有感觉烦,就是害怕来不及.所以抓紧了.下面直接正题.说一下用到的东西,都是Google搜 ...
- smarty函数-转载
Smarty常用函数 2009-08-13 14:05:55| 分类: Php |举报 |字号 订阅 1 .include_once语句: 引用文件路径,路径必需正确. eg:include ...
- unity3d 2d游戏制作的模式
经过了4个月不懈的努力,我和图灵教育合作的这本3D游戏开发书预计下个月就要出版了.这里MOMO先打一下广告,图灵的出版社编辑成员都非常给力,尤其是编辑小花为这本书付出了很大的努力,还有杨海玲老师, ...
- Latex beamer
使用明体(gbsn)和楷体(gkai)两种字型.以下的编程是一开始的宣告,并自动生成第一张封面投影片. \documentclass[cjk]{beamer}\usepackage{CJKutf8}\ ...