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 ...
随机推荐
- cmd命令 拷贝某文件夹及其子文件夹文件到其它文件夹
@ECHO OFF cd/d %H:\FileLoc\CNET&cd.. ::echo 拷贝"%H:\FileLoc\CNET"中文件到"H:\FileLocTe ...
- 机器学习Matlab打击垃圾邮件的分类————朴素贝叶斯模型
该系列来自于我<人工智能>课程回顾总结,以及实验的一部分进行了总结学习机 垃圾分类是有监督的学习分类最经典的案例,本文首先回顾了概率论的基本知识.则以及朴素贝叶斯模型的思想.最后给出了垃圾 ...
- objective-c 中代码块(blocks)
在ios4之后,引入了代码块的特性,在gcd中会经常的用到,所以决定好好的看看代码块文档,把这块总结一下.从头开始讲解代码块. 1.声明和使用代码块 一般用^操作符声明一个块变量,并作为块的开始符.而 ...
- asp.net DropDownList实现ToolTip功能
在绑定DropDownList控件时,可能出现绑定显示的文本过长以至于超过控件长度的内容看不到,这时候就需要使用ToolTip完成其功能,即鼠标放到相应选项后就可显示其完成内容. 首先,在页面引入jQ ...
- HTML系列(八):表格
一.基本表格: 表格标记<table>,行标记<tr>,单元格标记<td> 基本语法: <table> <tr> <td>单元格 ...
- debug jdk
1.解压jdk安装路径中的src.zip如:c:\src. 注意一般只选择编译java javax org 三个文件夹就足够了,剩余的文件夹删除掉 2.列出要编译的源文件:dir /B /S /X c ...
- 红豆带你从零学C#系列之:开始C#编程(二)
控制台程序开发之补充说明 你已经动手操作过我们上一篇文章中的控制台程序输入输出了吗朋友? 如果没有的话,强烈建议你先回去做一遍再来继续学习噢!上一篇文章地址:点击这里 一. 你问我答 问:代码是 ...
- Java学习之ThreadLocal
转自:http://www.cnblogs.com/doit8791/p/4093808.html#3197185 在同步机制中,通过对象的锁机制保证同一时间只有一个线程访问变量.这时该变量是多个线程 ...
- bootstrap你让前端小狮子们又喜又恨
看了一个用bootstrap框架建的页面,简直方便至极!各种添加类就可以实现各种功能,各种添加data-toggle让你不需要懂javascript就可以做出很炫的效果! 最重要的它做出来的页面还是响 ...
- sublime模式下开启vim并修改esc
首先我用的是sublime text2 sublime下开启vim模式: 在Preference -> Setting-User里面加上 "ignored_packages" ...