Hdoj 1753 daming a+b High precision/java

Source: Internet
Author: User

Daming A+b

Time limit:3000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 9273 Accepted Submission (s): 3318


problem DescriptionSay, after a long one months, Xiaoming has grown a lot, so he changed a name called "Daming".
At this time he is not the only one who will do the addition of the "Xiao Ming", and now he will even arbitrary length of the addition of the positive decimal.

Now, give you two positive decimals A and B, your task is to calculate the value of A+b on behalf of Daming.

InputThis topic contains multiple sets of test data, please process to the end of the file.
Each set of test data contains two positive decimals A and B with a length of not more than 400 in a row.

OutputPlease output the output a+b value in one line, please output the simplest form. Please see sample Output for detailed requirements.

Sample Input1.1 2.91.1111111111 2.34443233431 1.1

Sample Output43.45554344542.1 SolvingGod C++,java Dafa Good people doing, days in the look, not believe Baidu Nine C + +
Import java.util.*; Import java.io.*; Import Java.math.*;  Public classmain{ Public Static voidMain (string[] args) {Scannerinch=NewScanner (System.inch);  while(inch. Hasnext ()) {BigDecimal a=inch. Nextbigdecimal (); BigDecimal b=inch. Nextbigdecimal (); System. out. println (A.add (b). Striptrailingzeros (). toplainstring ()); //stripxxxx Remove the rear 0//Toplainstring is the return of the ordinary counting method        }    }   }  

Hdoj 1753 daming a+b High precision/java

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.