

注解
1、直接利用Java大数类BigInteger,计算mod。
代码
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
BigInteger bi = new BigInteger(sc.next());
BigInteger bi2 = new BigInteger(sc.next());
System.out.println(bi.mod(bi2));
}
}
}
结果

本文介绍了一种使用Java的BigInteger类进行大数运算的方法,特别关注了模运算(mod)。通过实例代码展示了如何输入两个大数并计算它们之间的模结果。
120

被折叠的 条评论
为什么被折叠?



