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. padding-bottom布局解析;

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. linux 自旋锁

    一.概述: 自旋锁是SMP架构中的一种low-level的同步机制.当线程A想要获取一把自旋锁而该锁又被其它线程锁持有时,线程A会在一个循环中自旋以检测锁是不是已经可用了.对于自选锁需要注意: 由于自 ...

  3. 【转】引入android项目在eclipse ADT中显示中文乱码问题

    (1)修改工作空间的编码方式:Window->Preferences->General->Workspace->Text file Encoding在Others里选择需要的编 ...

  4. C++/C#结构体转化-传string给C++

    此例是把C#结构传给C++ C++: typedef struct VidyoClientInEventGroupChat_ { /*! Message (contents) to be sent t ...

  5. STL模板_概念

    模板和STL一.模板的背景知识1.针对不同的类型定义不同函数版本.2.借助参数宏摆脱类型的限制,同时也因为失去的类型检查而引 入风险.3.借助于编译预处理器根据函数宏框架,扩展为针对不同类型的 具体函 ...

  6. Android 开发之Matrix图片处理类的使用

    在Android中,对图片的处理需要使用到Matrix类,Matrix是一个3 x 3的矩阵,他对图片的处理分为四个基本类型: 1.Translate————平移变换 2.Scale————缩放变换 ...

  7. Web存储(Web Storage)介绍

    Web存储即在客户端存储数据. 在没有Web Storage之前,是通过cookie来在客户端存储数据的.但是由于 浏览器能存cookie数比较少.如IE8,Firefox,opera每个域可以保存的 ...

  8. django学习之Model(五)MakingQuery

    接着上篇. 10-一次更新多个对象 有时想要对QuerySet中的所有对象的某一个field来设定一个值,这时候可以像下边这样用update(): # Update all the headlines ...

  9. JAVA并发,后台线程

    package com.xt.thinks21_2; import java.util.concurrent.TimeUnit; /** * 后台线程测试 * * @author Administra ...

  10. Linux中的IO复用接口简介(文件监视?)

    I/O复用是Linux中的I/O模型之一.所谓I/O复用,指的是进程预先告诉内核,使得内核一旦发现进程指定的一个或多个I/O条件就绪,就通知进程进行处理,从而不会在单个I/O上导致阻塞. 在Linux ...