比较重要的几条是:
add, subtract, multiply, divide, mod, remainder
加减乘除取模取余—注意取模中 \(b\) 必须为正!a.compareTo(b)
\(a=b\) 返回 \(0\), 否则返回 \(a>b\) 的值.a.toString(b)
将 \(a\) 转换为 \(b\) 进制字符串.
另外注意 Scanner
的写法:
- 输入接口:
Scanner cin = new Scanner(System.in);
- EOF写法:
while(cin.hasNext()) {}
- 输入:
BigInteger a = cin.nextBigInteger();
以及变量的声明(注意 new
):
- 单个变量:
BigInteger a = new BigInteger("0");
- 声明数组:
BigInteger a[] = new BigInteger[size];
- 静态方法:
BigInteger a = BigInteger.valueOf(x);
完整版本如下:
来源: https://blog.csdn.net/qq644262163/article/details/53116713
1 | import java.util.*; |