Integer Inquiry

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 9376    Accepted Submission(s): 2406

Problem 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.

This problem contains multiple test cases!

The first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.

The output format consists of N output blocks. There is a blank line between output blocks.

 
Sample Input
1

123456789012345678901234567890
123456789012345678901234567890
123456789012345678901234567890
0

 
Sample Output
370370367037037036703703703670
 
Source
 

import java.math.BigInteger;
import java.util.Scanner; public class Main {//没咋看懂是怎么输入的
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
while(input.hasNext()){
int n=input.nextInt();
while(n-->0){
BigInteger sum=BigInteger.valueOf(0);
BigInteger a;
while(!(a=input.nextBigInteger()).equals(BigInteger.valueOf(0))){
sum=sum.add(a);
}
System.out.println(sum);
if(n>0)
System.out.println();
}
}
}
}

Integer Inquiry_hdu_1047(大数).java的更多相关文章

  1. Cannot convert 0 of type class java.lang.Integer to class java.lang.Boolean

    org.apache.catalina.core.ApplicationDispatcher invoke SEVERE: Servlet.service() for servlet jsp thre ...

  2. Provided id of the wrong type for class pojo.Books. Expected: class java.lang.Integer, got class java.lang.Long

    log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment). log4j:WARN Please ...

  3. HDU 1715 大数java

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

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

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

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

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

  6. HDU1134/HDU1133 递推 大数 java

    Game of Connections Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Othe ...

  7. HDU1063 大数 java

    Exponentiation Time Limit: 2000/500 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  8. How Many Fibs_hdu_1316(大数).java

    How Many Fibs? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) T ...

  9. 大数java(pow)

    Problems involving the computation of exact values of very large magnitude and precision are common. ...

随机推荐

  1. jsp接收相同复合参数 request.getParameterValues()用法

    在网站中往往需要用户选择复选框,此时需要创建多个复选框让用户进行选择: <head> <meta http-equiv="Content-Type" conten ...

  2. Jmeter Constant Throughput Timer 使用

    Jmeter提供了一个非常有用的定时器,称为Constant Throughput Timer (常数吞吐量定时器),该定时器可以方便地控制给定的取样器发送请求的吞吐量. 右键点击fnng.cnblo ...

  3. 如何查看Linux的磁盘空间还有多少

    无论是Linux还是unix,都提供了很多工具来查看磁盘空间的大小. 1. df命令,df命令,可以查看当前文件系统占用的空间的大小,以及剩余的大小,如下例子: Filesystem     1K-b ...

  4. [unity菜鸟] 修改发布成web后的logo

    1. 原始效果  (tip:在4.x的书中有介绍) 2. 打开.html文件原始代码如下 <script type='text/javascript' src='jquery.min.js'&g ...

  5. ANDROID_MARS学习笔记_S01原始版_004_TableLayout

    1.xml <?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android ...

  6. 气死人不偿命,Q_OBJECT导致的C++报错,而且还看不明白(#ifdef没控制好,导致什么都不认识了)

    为了代码可以同时适应VC++和MingW编译器,我改动了我的代码,变成: #ifdef _MSC_VER #pragma comment(lib, "crypt32.lib") / ...

  7. Layout Resource官方教程(2)用ViewStub引用的嵌入的layout可推迟加载

    Loading Views On Demand THIS LESSON TEACHES YOU TO Define a ViewStub Load the ViewStub Layout YOU SH ...

  8. C++文件读写总结

    在C++中如何实现文件的读写? 作者: infobillows 发表日期: 2007-04-03 21:33 点击数: 465 一.ASCII 输出 为了使用下面的方法, 你必须包含头文件<fs ...

  9. Java Memory Management(1)

    Java Memory Management, with its built-in garbage collection, is one of the language’s finest achiev ...

  10. hadoop2.2原理:采样器

    多输入路径-只采一个文件-(MultipleInputs+getsample(conf.getInputFormat) 之前弄采样器,以为已经结束了工作,结果现在又遇到了问题,因为我的输入有两个文件, ...