1005 大数加法 ——51Nod(java BigInteger)

基准时间限制:1 秒 空间限制:131072 KB

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

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

Output
输出A + B

Input示例
68932147586
468711654886

Output示例
537643802472

思路:
用java的BigInteger来写比较省事(其实就是高精度运算菜的扣脚~唉)

代码:

import java.util.*;
import java.math.*;

public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner in = new Scanner(System.in);
        BigInteger big1 = in.nextBigInteger();
        BigInteger big2 = in.nextBigInteger();
        System.out.println(big1.add(big2));
    }

}
原文地址:https://www.cnblogs.com/vocaloid01/p/9514231.html