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. microsofr visual studio编写c语言

    过程: 1.创建win32 控制台项目 文件->新建->项目->Visual C++ ->Win32   输入项目名称   选择项目保存位置 2.添加->新建如图

  2. java1.8中Lambda表达式reduce聚合测试例子

    public class LambdaTest { public static void main(String[] args) { // 相当于foreach遍历操作结果值 Integer out ...

  3. JUnit笔记

  4. hadoop2.x NameNode 的共享存储实现

    过去几年中 Hadoop 社区涌现过很多的 NameNode 共享存储方案, 比如 shared NAS+NFS.BookKeeper.BackupNode 和 QJM(Quorum Journal ...

  5. 三、jQuery--jQuery插件--jQuery插件——Validation Plugin

    简介: 客户端验证:现代网站填写表单时,几乎一定会采用的方式. 优点:1.可以减少服务器压力 2.缩短用户等待时间和提升用户体验 jQuery有很多表单验证插件:https://plugins.jqu ...

  6. Lattice Diamond 的学习之新建工程

    1).打开软件 在软件打开后的初始布局会有一个Start  page 可以创建.打开.导入一个ISPLEVER 工程. 2).建立工程:1,Start page 中Project --> NEW ...

  7. smarty汇总

    Smarty:模板技术 实现功能:前后分离. 原理:主要通过Smarty核心类实现,调用display方法,将模板文件读取,用正则进行替换,替换完保存到临时文 件,将临时文件加载到当前页面. 配置文件 ...

  8. sdut 2441 屠夫与狼

    屠夫和狼 Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 题目链接:http://acm.sdut.edu.cn/sdutoj/p ...

  9. php获取文件夹下面的文件列表和文件夹列表

    function getDir($dir) { $dirArray[] = NULL; if (false != ($handle = opendir( $dir ))) { $i=0; while ...

  10. [Skills] 在桌面打开一个BAT文件,CMD窗口不关闭

    每次开机都要取得本机IP,然后远程连接上去,屏幕太小,不好输入,想写个bat,执行就能看到IP,并且停留在cmd窗口上,想来简单,以前搜了好久没找到好的办法,今天找到一个贴子,竟然可以,呵呵!   以 ...