华为笔试——第三题 大数相乘

大数相乘
输入:
-12341234
43214321
输出:
-533318047612114

1、利用BigInteger

public class Main{

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner s= new Scanner(System.in);
        BigInteger n = s.nextBigInteger();
        BigInteger m = s.nextBigInteger();
        System.out.println(n.multiply(m));  

    }


}

2、字符串处理方式:

猜你喜欢

转载自blog.csdn.net/hyeeee/article/details/79649904