大数加法 51Nod - 1005

版权声明: https://blog.csdn.net/nucleare/article/details/82989001

大数加法

 51Nod - 1005 

给出2个大整数A,B,计算A+B的结果。

Input

第1行:大数A 
第2行:大数B 
(A,B的长度 <= 10000 需注意:A B有可能为负数)

Output

输出A + B

Sample Input

68932147586
468711654886

Sample Output

537643802472
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		BigDecimal a, b, c;
		Scanner shuru;
		shuru = new Scanner(System.in);
		while (shuru.hasNext()) {
			a = shuru.nextBigDecimal();
			b = shuru.nextBigDecimal();
			c = a.add(b);
			System.out.println(c);
		}
	}

}

猜你喜欢

转载自blog.csdn.net/nucleare/article/details/82989001
今日推荐