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
第一道java题,好开森;
import java.util.*; import java.math.*; import java.io.*;
public class Main{        //外面的Main必须大写! public static void main(String[] args){ //String S大写 Scanner cin= new Scanner(System.in);
BigDecimal a=BigDecimal.valueOf(0); //组合的函数名一般后个一定得大写: BigInter BigDecimal valueOf(这前不大写) hasNext nextLine;
BigDecimal b=BigDecimal.valueOf(0); //赋初值
String str;
while(cin.hasNext())     //相当于!=EOF
{
str=cin.nextLine(); //下一行输入nextLine
if(str.equals("0")) //equals
{
break;
}
else
{
a=new BigDecimal(str); //强制转化,把str转化成大数
b=b.add(a);     //b+a; } }
System.out.println(b.toPlainString()); //println,是LN
                        //toPlainString 以字符形式输出
} }

  

poj-1503-java大数相加的更多相关文章

  1. Java大数相加-hdu1047

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1047 题目描述: 题意有点绕,但是仔细的读了后就发现是处理大数相加的问题.注意:输入数据有多组,每组输 ...

  2. java大数相加

    import java.math.BigInteger; import java.util.Scanner; public class Bignum{    public static void ma ...

  3. hdu1715(Java)大数相加

    大菲波数 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submissio ...

  4. hdu 1002 java 大数相加

    package Main; //import java.io.InputStream; import java.math.BigDecimal; import java.util.Scanner; p ...

  5. hdu1047(Java)大数相加

    题目大意:输入n组数据,每组数据中又有若干长度不大于100的整数,以0结束每组数据的输入,求每组中数据之和.每两组数据输入之间有一行空格,输出也是如此. Integer Inquiry Time Li ...

  6. Java大数相加(多个大数相加)-hdu1250

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1250 题目描述: 题目大意是:已知一个Hat's Fibonacci序列,该序列满足F(1) = 1, ...

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

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

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

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

  9. Java实现大数相加、相乘(不使用BigInteger)

    大数相加: package algorithm; //使用BigInteger类验证 import java.math.BigInteger; public class BigAdd { public ...

  10. Poj 2602 Superlong sums(大数相加)

    一.Description The creators of a new programming language D++ have found out that whatever limit for ...

随机推荐

  1. ORACLE透明网关访问SQL Server配置总结

      透明网关概念 ORACLE透明网关(Oracle Transparent Gateway)可以解决ORACLE数据库和非ORACLE数据库交互数据的需求.在一个异构的分布式环境中,通过ORACLE ...

  2. 判断一个jquery对象是否为空

    今天用jquery $获取一个jquery对象.$("#id") 然后用判断这个对象是否存在,id不存在的时候,判断这个是否存在, if($("#id")) 始 ...

  3. PHP解码unicode编码中文字符代码

    function replace_unicode_escape_sequence($match) { return mb_convert_encoding(pack('H*', $match[1]), ...

  4. 【javascript】jQuery判断用户右击事件

    jquery 判断用户是鼠标是右击还是左击, // 1 = 鼠标左键 left; 2 = 鼠标中键; 3 = 鼠标右键 $(document).mousedown(function(e) { if(3 ...

  5. Caused by:java.sql.SQLException:ORA-00923

    1.错误描述 Caused by:java.sql.SQLException:ORA-00923:未找到要求的FROM关键字 2.错误原因 拼接SQL语句时缺少FROM什么表,导致出错 3.解决办法 ...

  6. java打印等腰三角形的两种方法!(根据行数,根据底边长度)

    首先来看根据用户输入的底边的长度判断: package cn.edu.nwpu.java; import java.util.Scanner; public class IsoscelesTriang ...

  7. mfc100u.dll下载和使用方法

      当运行软件或游戏时,系统提示"丢失mfc100u.dll"."没有找到mfc100u.dll"等类似错误信息. 请下载本站提供的dll文件,使用它可以帮助用 ...

  8. 创建元素节点createElement

    <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...

  9. 获取SHA1

    进入命令行,依次输入: 此处密钥默认为android.

  10. 基于python自动化测试平台与虚拟化技术结合的思考

    背景: 自动化测试行业内,个人觉得主力语言是python.java.这里讨论下基于python自动化框架设计与case开发,用过python的都知道它的好处,但是根据实际项目需要有了很多迎面而来的困难 ...