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. Angularjs的真分页,服务端分页,后台分页的解决方案

    背景:项目的框架使用的是Angularjs,在做数据展示的时候,使用的是ng-table.用过ng-table的人都知道,他是自带分页的,默认分页方式是假分页.也就是一口气把所有的数据从数据库里取出来 ...

  2. jQuery中的val()

    jQuery中的val() 1.实例源码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &qu ...

  3. AM335x(TQ335x)学习笔记——触摸屏驱动编写

    前面几篇文章已经通过配置DTS的方式完成了多个驱动的移植,接下来我们解决TQ335x的触摸驱动问题.由于种种原因,TQ335x的触摸屏驱动是以模块方式提供的,且Linux官方内核中也没有带该触摸屏的驱 ...

  4. 草料Chrome浏览器插件,让二维码更好用

    安装插件草料chrome插件,是专为chrome核心的浏览器开发的一个二维码应用增强工具插件. 自动将地址栏链接生成二维码 以谷歌原生的chrome浏览器为例,插件安装成功后会在浏览器地址栏旁边出现一 ...

  5. Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL

    1.错误描述 org.hibernate.exception.SQLGrammarException: error executing work at org.hibernate.exception. ...

  6. ArcGIS For Flex报错二

    1.错误描述 2.错误原因 3.解决办法

  7. Openstack_O版(otaka)部署_准备环境和依赖软件

    架构介绍 本次案列为基本的三节点部署 一:网络: 1.管理网络:192.168.198.0/24 2.数据网络:10.0.0.0/24 二:操作系统: CentOS Linux release 7.3 ...

  8. 如果没有Build path怎么办 .project文件的修改

    <?xml version="1.0" encoding="UTF-8"?><projectDescription> <name& ...

  9. form表单的action提交写到js中来,同时onclick事件也写在js中来。其action也可以通过ajax来提交的。

    1,html脚本 <body> <div style="display: none;"> <form id="submitForm" ...

  10. PyTorch官方中文文档:torch.optim

    torch.optim torch.optim是一个实现了各种优化算法的库.大部分常用的方法得到支持,并且接口具备足够的通用性,使得未来能够集成更加复杂的方法. 如何使用optimizer 为了使用t ...