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. IgnoreRoute——注册路由

    routes.IgnoreRoute("home/about"); 这句话,当Route遇到Home/About的Url时,这段URL将被忽略. 效果图 需要注意的是这里route ...

  2. sql 复杂自动编号错误批量修改方案

    [一篮饭特稀原创,转载请注明出自http://www.cnblogs.com/wanghafan/p/5133953.html]  前提:自动编号为18位,前4位是年份,中间10位是XXXX,最后四位 ...

  3. iOS开发UI篇—UITabBarController生命周期(使用storyoard搭建)

    iOS开发UI篇—UITabBarController生命周期(使用storyoard搭建)   一.UITabBarController在storyoard中得搭建 1.新建一个项目,把storyb ...

  4. 李洪强漫谈iOS开发[C语言-016]-变量的作用域

  5. leetcode面试准备:Sliding Window Maximum

    leetcode面试准备:Sliding Window Maximum 1 题目 Given an array nums, there is a sliding window of size k wh ...

  6. C++11 中的线程、锁和条件变量

    转自:http://blog.jobbole.com/44409/ 线程 类std::thread代表一个可执行线程,使用时必须包含头文件<thread>.std::thread可以和普通 ...

  7. SSH框架应用中常用Jar包用途介绍

    struts2需要的几个jar包:1)xwork-core-2.1.62)struts2-core-2.1.83)ognl-2.7.34)freemarker-2.3.155)commons-io-1 ...

  8. cogs_14_搭配飞行员_(二分图匹配+最大流,网络流24题#01)

    描述 http://cojs.tk/cogs/problem/problem.php?pid=14 有一些正飞行员和副飞行员,给出每个正飞行员可以和哪些副飞行员一起飞.一架飞机上必须一正一副,求最多多 ...

  9. 转自 z55250825 的几篇关于FFT的博文(三)

    题目大意:给出n个数qi,定义 Fj为        令 Ei=Fi/qi,求Ei.      其实这道题就是看到有FFT模板才觉得有必要学一下的...    所以实际上就是已经知道题解了... = ...

  10. jQuery里面的datepicker日期控件默认是显示英文的,如何显示中文或其他语言呢?

    jQuery里面的datepicker日期控件默认是显示英文的,如何让他显示中文或其他呢? [官方的写法]: (1)引入JS文件: <script type="text/javascr ...