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

Description

题目链接:http://poj.org/problem?id=1503

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

Source

题目描述:输入多个大数,求其和,输入以0结束。
代码:

 #include<iostream>
#include<string.h>
#include<stdlib.h>
using namespace std;
int main()
{
char f1[];
int sum[]={},i,j;
cin>>f1;
while(strcmp(f1,"")!=)
{
int t=strlen(f1),f[]={};
for(i=t-,j=;i>=;i--,j++)
f[j]=f1[i]-'';
int up=;
for(j=;j<=;j++)
{
int s=f[j]+sum[j]+up;
sum[j]=s%;
up=s/;
}
cin>>f1;
}
for(i=;i>=;i--)
if(sum[i]!=)
{
while(i>=)
{
cout<<sum[i];
i--;
}
break;
}
cout<<endl;
return ;
}

Integer Inquiry【大数的加法举例】的更多相关文章

  1. Integer Inquiry 大数加法

    Integer Inquiry 1 import java.util.*; 2 import java.math.*; 3 import java.io.*; 4 import java.text.* ...

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

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

  3. POJ 1503 Integer Inquiry(大数相加,java)

    题目 我要开始练习一些java的简单编程了^v^ import java.io.*; import java.util.*; import java.math.*; public class Main ...

  4. POJ 1503 Integer Inquiry(大数相加)

    一.Description One of the first users of BIT's new supercomputer was Chip Diller. He extended his exp ...

  5. HDU 1047 Integer Inquiry 大数相加 string解法

    本题就是大数相加,题目都不用看了. 只是注意的就是HDU的肯爹输出,好几次presentation error了. 还有个特殊情况,就是会有空数据的输入case. #include <stdio ...

  6. POJ 1503 Integer Inquiry 大数 难度:0

    题目链接:http://poj.org/problem?id=1503 import java.io.*; import java.math.BigInteger; import java.util. ...

  7. Integer Inquiry(大数相加)

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

  8. HDU 1047 Integer Inquiry( 高精度加法水 )

    链接:传送门 思路:高精度水题 /************************************************************************* > File ...

  9. UVa 424 Integer Inquiry 【大数相加】

    解题思路:因为给定的数据是多组,所以我们只需要多次做加法就可以了,将上一次的和又作为下一次加法运算的一个加数. 反思:还是题意理解不够清楚,最开始以为只是算三个大数相加,后来才发现是多个,然后注意到当 ...

随机推荐

  1. PHP 中的行为 ,与什么是切面

    行为(Behavior)扩展以及插件(Plug or Hook)详解: 行为(Behavior)是ThinkPHP扩展机制中比较关键的一项扩展,行为即可以独立调用,也可以绑定到某个 标签中进行监听,官 ...

  2. js清空array数组的方法

    方式1,splice Js代码   ,,,}; ary.length = ; Java中会报错,编译通不过. 而JS中则可以,且将数组清空了,如 Js代码   var ary = [1,2,3,4]; ...

  3. tinyhttp源码阅读(注释)

    这里就不细述了,代码很简单. 其实现的功能比较若,可以做一个参考. 因为其通过文件的权限位来判断是否是一个CGI脚本,所以在权限位不对的情况下会判断不正确.例如我将这个目录放置在NTFS分区,所有的文 ...

  4. PictureCutting图片批量裁切(裁剪)工具

    PictureCutting图片批量裁切(裁剪)工具 写这个工具的原因是因为在获取一个软件的皮肤包中的图片的时候需要进行批量的裁切工作,而有没有找到在linux下简单好用的工具,干脆就用QT写了一个. ...

  5. Python自动化之配置Python模块国内镜像

    Linux环境 在~/.pip/pip.conf文件中添加或修改 [global] index-url = http://mirrors.aliyun.com/pypi/simple/ [instal ...

  6. 在Navicat for MySQL中打开视图时,提示视图没有主键的问题

    一直把视图理解为一个select语句而已,视图一般就是用于查询,不会通过视图来更新表或视图本身的数据,所以视图根本不需要什么主键.今天自己建了一个视图view_test: drop view if e ...

  7. 三大UML建模工具Visio、Rational Rose、PowerDesign的区别

    本文源自http://developer.51cto.com/art/201006/207993.htm UML建模工具Visio .Rational Rose.PowerDesign的比较   RO ...

  8. 【GoLang】golang 交叉编译 实现&工具

    apt-get install gcc-mingw-w64 env CGO_ENABLED= GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc g ...

  9. 【GoLang】GoLang 的流程与函数

    003.GO流程与函数 1 概述 1.1 Go中流程控制分三大类:条件判断,循环控制和无条件跳转 2 流程 2.1 if 2.1.1 if条件判断语句中不需要括号 2.1.2 条件判断语句里面允许声明 ...

  10. Interleaving Positive and Negative Numbers

    Given an array with positive and negative integers. Re-range it to interleaving with positive and ne ...