Integer Inquiry 

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
import java.util.*;
import java.io.*;
import java.math.*;
import java.text.*;
public class IntegerInquiry {
public static void main(String[] args){
Scanner sc = new Scanner(new BufferedInputStream(System.in));
BigDecimal bd, ans;
ans = new BigDecimal("0");
while(sc.hasNext()){
bd = new BigDecimal(sc.next());
if(bd.equals(new BigDecimal("0")))
break;
ans = ans.add(bd);
}
System.out.println(ans);
}
}

424 - Integer Inquiry的更多相关文章

  1. UVa 424 Integer Inquiry

    之前杭电上也做过a + b的高精度的题,不过这道题的区别是有多组数据. 之前做的时候开了3个字符数组a,b,c,在计算的时候还要比较a,b长度,短的那个还要加'0',还设置了一个add来存放进位. 现 ...

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

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

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

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

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

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

  5. hdu1047 Integer Inquiry

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

  6. Integer Inquiry

    Integer Inquiry Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u Sub ...

  7. hdu 1047 Integer Inquiry

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

  8. Poj 1503 Integer Inquiry

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

  9. hdoj 1047 Integer Inquiry

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

随机推荐

  1. c++中有些重载运算符为什么要返回引用

    事实上,我们的重载运算符返回void.返回对象本身.返回对象引用都是可以的,并不是说一定要返回一个引用,只不过在不同的情况下需要不同的返回值. 那么什么情况下要返回对象的引用呢? 原因有两个: 允许进 ...

  2. Mysql复制之路由

    在主从复制读写分离的思路下,要想使所有写都到MasterServer,所有读都路由到Slave Server;就需要使用一些路由策略. 可以使用MysqlProxy[Mysql代理],据说MysqlP ...

  3. 手写代码自动实现自动布局,即Auto Layout的使用

    手写代码自动实现自动布局,即Auto Layout的使用,有需要的朋友可以参考下. 这里要注意几点: 对子视图的约束,若是基于父视图,要通过父视图去添加约束. 对子视图进行自动布局调整,首先对UIVi ...

  4. C++面试之GetMemory问题

    http://blog.csdn.net/zhuxiaoyang2000/article/details/8084629 #include <iostream> #include < ...

  5. 通过mysql命令行理解mysql

    引言:工具不可谓给我们的生活带来了便利,但有些时候我们却忘记了事物本身的意义.在大多数人都在追捧甚至是盲从各种各样的工具有多先进的时候,你是否有反思过:你目前是否有使用它的资格. 假设你学会了使用一款 ...

  6. Jmeter 函数

    一._csvRead 函数 _cvsRead函数是从外部读取参数,csvRead函数可以从一个文件中读取多个参数. 步骤: 1.先新建一个文件,例如c.txt,里面的数据存放为 web@qq.com, ...

  7. iis 7.5应用程序池自动停止

    今天在我的windows7旗舰版上配置iis7 (Internet Information Server)失败,一直未能启动服务,访问本地网络提示"Service Unavailable H ...

  8. IIS网站发布若干问题

    1.Win7 64位 IIS未能加载文件或程序集"System.Data.SQLite"或它的某一个依赖项   未能加载文件或程序集"System.Data.SQLite ...

  9. 与你相遇好幸运,Sails.js安装

    官网: http://sailsjs.org Github:https://github.com/balderdashy/sails 开发文档: http://sailsjs.org/document ...

  10. SQL Server排序规则

    在使用数据库的过程中,总会碰到一些特别的需求.有时候需要储存中文字符,区分大小写或者按照中文的比划顺序排序.这就涉及到了对数据库排列规则的选择. 我们一般可以选择数据库名称-->右键属性(Pro ...