Java实现 蓝桥杯 算法提高 高精度减法(JDK方法)

试题 算法提高 高精度减法

问题描述
  高精度减法
输入格式
  两行,表示两个非负整数a、b,且有a > b。
输出格式
  一行,表示a与b的差
样例输入
1234567890987654321

9999
样例输出
1234567890987644322

 

import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        BigInteger big1 = new BigInteger(sc.next());
        BigInteger big2 = new BigInteger(sc.next());
        sc.close();
        System.out.println(big1.subtract(big2));
    }
}

posted @ 2020-04-29 11:52  南墙1  阅读(75)  评论(0编辑  收藏  举报