九度oj-1119-Integer Inquiry

原创 2015年11月17日 18:38:35

时间限制:1 秒

内存限制:32 兆

特殊判题:

提交:682

解决:360

题目描述:

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

输入:

    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.

输出:

    Your program should output the sum of the VeryLongIntegers given in the input.

样例输入:
123456789012345678901234567890
123456789012345678901234567890
123456789012345678901234567890
0
样例输出:
370370367037037036703703703670
import java.util.Scanner;
import java.math.BigInteger;

public class Main{	
	public static void main(String[] args){
		Scanner in=new Scanner(System.in);
		BigInteger a=BigInteger.ZERO,b;
		while(in.hasNext()){
			b=in.nextBigInteger();
			if(b.equals(BigInteger.ZERO)) break;
			a=a.add(b);
		}
		System.out.println(a);
		in.close();
	}
}


相关文章推荐

九度OJ 1119 Integer Inquiry

题目描述:     One of the first users of BIT's new supercomputer was Chip Diller.     He extended his...
  • ronixy
  • ronixy
  • 2014年03月04日 13:12
  • 397

九度 oj 题目1119:Integer Inquiry

http://ac.jobdu.com/problem.php?pid=1119 #include #include #include int main(){ //freo...

九度OJ 1119 Integer Inquiry

题目描述:     One of the first users of BIT's new supercomputer was Chip Diller.     He extended his...

POJ1503-Integer Inquiry

  • 2011年07月29日 20:38
  • 6KB
  • 下载

九度OJ八皇后问题

  • 2013年04月09日 23:47
  • 3KB
  • 下载

POJ 1503 Integer Inquiry

题目描述: 输入一组以0结尾的超级大数,输出这些超级大数相加的结果。 思路: 题目较为简单,但是如果直接利用数值类型存储组内数据是行不通的,因此利用字符串存储输入数据,计算结果以字符串输出。 ...
  • furney
  • furney
  • 2011年12月30日 15:19
  • 613

HDU 1047 Integer Inquiry

 Integer Inquiry Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 655...

POJ 1503 Integer Inquiry 简单大数相加

DescriptionOne of the first users of BIT’s new supercomputer was Chip Diller. He extended his explor...

hdu1047 Integer Inquiry 多次大数相加

多次大数相加
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:九度oj-1119-Integer Inquiry
举报原因:
原因补充:

(最多只允许输入30个字)