import java.math.BigInteger; import java.util.Scanner;
in = Scanner (System.in);
输入
while(in.hasNext()) //等价于!=EOF,循环读入数据int n=in.nextInt(); //读入一个int型的数
String s=new String()
s=in.nextLine(); //读入字符串
BigInteger m=in.nextBigInteger(); //读入一个大整数
输出:
System.out.print(n); //打印n
System.out.println(); //换行System.out.printf("%d\n",n); //也可以类似c++里的输出方式
BigInteger.valueOf(int n) //大数类型
BigInteger a=new BigInteger(“100”)
大数 a 调用以下函数
add(BigInteger n); //加法
subtract(BigInteger n) //减法
multiply(BigInteger n) //乘法
divide(BigInteger n) //除法
remainder(BigInteger n) //取余(模)
divideAndRemainder(BigInteger n):a[0]=this / n; a[1]=this % n //除数加余数
compareTo(BigInteger n) //大于返回1,等于0,小于-1
pow(int b)=a^b //幂函数
modPow(BigInteger n,BigInteger m) a^n%m //幂函数模
min(BigInteger n) ,max(BigInteger n) //取两个数的较小、大者
intValue(),longValue(),floatValue(),doublue() //返回该类型的数的值。
gcd(BigInteger n) //公约数
abs(BigInteger n) //绝对值
isProbablePrime(int n) //判断是否是素数,是返回true,否则返回false
negate () //取负数,无形参
and(BigInteger n) //&&, &;
or(BigInteger n) // ||,|;
xor(BigInteger n) //异或
toString() //返回转换成的字符串,无形参
toString(int n) //返回转换成n进制的字符串,无形参*
not() // ! 正数变负数,负数变正数,暂时不知实际意义