Daming A+B
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 14587 Accepted Submission(s): 5359
Problem Description
In other words, after a long month, Xiao Ming has grown a lot, so he changed his name to " Da Ming " . At this time, he was no longer the " Xiao Ming " who could only add within 100. Now he can even add positive decimals of any length. Now, given two positive decimals A and B , your task is to calculate the value of A+B on behalf of Daming .
Input
This question contains multiple sets of test data, please process until the end of the file. Each set of test data contains two positive decimals A and B whose length is not greater than 400 in one line .
Output
Please output the value of A+B in one line , please output the simplest form. See Sample Output for detailed requirements .
Sample Input
1.1 2.9
1.1111111111 2.3444323343
1 1.1
Sample Output
4
3.4555434454
2.1
Java large number template questions
import java.math.BigDecimal; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); BigDecimal a=BigDecimal.valueOf(0); BigDecimal b=BigDecimal.valueOf(0); while(cin.hasNext()) { a=cin.nextBigDecimal(); b=cin.nextBigDecimal(); System.out.println(a.add(b).stripTrailingZeros().toPlainString()); } } }