Hdu-1047-integer Inquiry (Java large number water problem && format nausea)

Source: Internet
Author: User

Integer InquiryTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 14886 Accepted Submission (s): 3811


Problem Descriptionone of the first users of BIT ' s new supercomputer was Chip Diller. He extended his exploration of powers's 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 for 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.)

Inputthe input would consist of in most of the lines of text, each of the which contains a single verylonginteger. Each verylonginteger'll be is fewer characters in length, and would only contain digits (no verylonginteger would be n egative).

The final input line would contain a single zero in a line by itself.

Outputyour 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 was an integer N and then a blank line followed by N input blocks. Each input block was 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
11234567890123456789012345678901234567890123456789012345678901234567890123456789012345678900

Sample Output
370370367037037036703703703670

Sourceeast Central North America 1996
Recommendwe carefully selected several similar problems for you:1063 1316 1715 1753 1018

The main meaning is to ask for three large number of the and, but to know first entered the first number of n indicates the number of test groups, that is, the number of empty rows per group, each block to a blank line! Then the last line does not empty line, this problem is very simple!
Import Java.math.biginteger;import Java.util.scanner;public class main{public static void Main (string[] args) {Scanner input = new Scanner (system.in), int n = input.nextint (), while (n--> 0) {BigInteger b = new BigInteger ("0"), while (input. Hasnextbiginteger ()) {BigInteger c = new BigInteger ("0"); c = Input.nextbiginteger (); if (!c.equals (biginteger.valueof (0 )) {B = B.add (c);} Else{system.out.println (b); if (n! = 0) {System.out.println ();} Break;}}} Input.close ();}}




Hdu-1047-integer Inquiry (Java large number water problem && format nausea)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.