Java HDU a+b for Input-output Practice (III)

Source: Internet
Author: User

A+b for Input-output Practice (III)

Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 113961 Accepted Submission (s): 60127


Problem Descriptionyour task is to Calculate A + B.

Inputinput contains multiple test cases. Each test case contains a pair of integers a and B, one pair of integers per line. A test case containing 0 0 terminates the-input and this-test case are not-to-be processed.

Outputfor each pair of input integers A and B are should output the sum of a and B in one line, and with one line of OUTPU T for each line in input.

Sample INPUT1 510 200 0

Sample Output630

Authorlcy

It is worth noting how to judge whether a large number is equal to a number, and how to convert a number to a large number form, note that a large number is essentially a string

ImportJava.math.BigInteger;ImportJava.util.Scanner; Public classMain//Note the Java format when you brush a question{     Public Static voidMain (string[] args) {BigInteger a,b,d; String C= "0"; D=NewBigInteger (c);//Convert c to large number form, save with DScanner in =NewScanner (system.in);  while(In.hasnextbiginteger ()) {a=In.nextbiginteger (); b=In.nextbiginteger (); if(A.compareto (d) = = 0 && B.compareto (d) = = 0)//Note that a large number of methods are used to determine whether the two large numbers are equal                 Break;        System.out.println (A.add (b)); }    }}

Java HDU a+b for Input-output Practice (III)

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.