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的更多相关文章

  1. hdu acm-1047 Integer Inquiry(大数相加)

    Integer Inquiry Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  2. Integer Inquiry【大数的加法举例】

    Integer Inquiry Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 27730   Accepted: 10764 ...

  3. hdu1047 Integer Inquiry

    /* Integer Inquiry Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...

  4. hdu 1047 Integer Inquiry

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1047 Integer Inquiry Description One of the first use ...

  5. Poj 1503 Integer Inquiry

    1.链接地址: http://poj.org/problem?id=1503 2.题目: Integer Inquiry Time Limit: 1000MS   Memory Limit: 1000 ...

  6. hdoj 1047 Integer Inquiry

    Integer Inquiry Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  7. (大数 string) Integer Inquiry hdu1047

    Integer Inquiry Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  8. HDUOJ-----1074 Integer Inquiry

    Integer Inquiry Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  9. 424 - Integer Inquiry

     Integer Inquiry  One of the first users of BIT's new supercomputer was Chip Diller. He extended his ...

随机推荐

  1. 清风注解-Swift程序设计语言:Point11~15

    目录索引 清风注解-Swift程序设计语言 Point 11. 数值型字面量 代码事例: let decimalInteger = // 十进制的17 let binaryInteger = 0b10 ...

  2. Windows Server 2012 R2超级虚拟化之六 Hyper-v Replica 2.0和Live migrations

    Windows Server 2012 R2超级虚拟化之六 Hyper-v Replica 2.0和Live migrations 分钟复制选项也是非常有用的.Hyper-V Replica 2.0在 ...

  3. 编辑器sublime text 加入到右键菜单

    方式一:     1. 运行中输入 regedit 打开注册表   2. 在HKEY_CLASSES_ROOT/*/shell/ 下新建’项’ ,名称自己觉得.我用的是Sublime Text   3 ...

  4. nodejs开发微信1——微信路由设置a(access_token和tickets)

    /* jshint -W079 */ /* jshint -W020 */ "use strict"; var _ = require("lodash"); v ...

  5. Image editing techniques and algorithms using Qt

    费了好半天劲先翻译这一点.还有好多地方不明白.先弄明白这一点.继续以后的翻译. 这一篇文章我们将讨论不同的技术和算法来修改图像使用Qt.但是在这之前我们继续你必须知道一些原则处理图片. 这里主要有两种 ...

  6. 算法导论——lec 10 图的基本算法及应用

    搜索一个图是有序地沿着图的边訪问全部定点, 图的搜索算法能够使我们发现非常多图的结构信息, 图的搜索技术是图算法邻域的核心. 一. 图的两种计算机表示 1. 邻接表: 这样的方法表示稀疏图比較简洁紧凑 ...

  7. QT 声明全局变量

    声明 qdatabasemanager.h #include"qdatabasemanager.h" externQDatabaseManager*Database; 引用 mai ...

  8. 从Excel转Access的一个方法说开去(DataRow的state状态)

    因为客户对access不太熟悉,更喜欢玩EXCEL.但是系统要求导入ACCESS.所以我们得做个把EXCEL转换成Access的小工具.(别问我为啥不让系统直接导入excel....我不知道!),然后 ...

  9. SQL标识列的查询

        1.判段一个表是否具有标识列    www.2cto.com   可以使用 OBJECTPROPERTY 函数确定一个表是否具有 IDENTITY(标识)列,用法: Select OBJECT ...

  10. linq中的GroupBy总结

    1.简单形式: var q = from p in db.Products group p by p.CategoryID into g select g; 语句描述:Linq使用Group By按C ...