import java.util.Scanner;
import java.math.*;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String s1 = sc.next();
String s2 = sc.next();
BigInteger a2 = new BigInteger(s1);
BigInteger b2 = new BigInteger(s2);
BigInteger result1=a2.add(b2); //加法
BigInteger result2 = a2.mod(b2); //a2 mod b2取余
BigInteger result3 = a2.multiply(b2); //乘法
BigInteger result4 = a2.divide(b2); //除法 a2/b2 b2 = 0.会终止程序,抛出异常
BigInteger result5 = a2.subtract(b2); //减法。a2 - b2.+
System.out.println (result1 );
System.out.println (result2 );
System.out.println (result3 );
System.out.println (result4 );
System.out.println (result5 );
}
}
利用java 快速实现加减乘数余运算
最新推荐文章于 2023-04-22 11:04:17 发布