目录
高精度 + 高精度
题目链接:http://bailian.openjudge.cn/practice/2981?lang=en_US
Accepted Code:
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner Scan = new Scanner(System.in);
BigInteger a = Scan.nextBigInteger();
BigInteger b = Scan.nextBigInteger();
System.out.println(a.add(b));
}
}
高精度 - 高精度
题目链接:http://bailian.openjudge.cn/practice/2736?lang=en_US
Accepted Code:
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner Scan = new Scanner(System.in);
BigInteger a = Scan.nextBigInteger();
BigInteger b = Scan.nextBigInteger();
System.out.println(a.subtract(b));
}
}
高精度 * 高精度
题目链接:http://bailian.openjudge.cn/practice/2980?lang=en_US
Accepted Code:
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner Scan = new Scanner(System.in);
BigInteger a = Scan.nextBigInteger();
BigInteger b = Scan.nextBigInteger();
System.out.println(a.multiply(b));
}
}
高精度 / 高精度
题目链接:http://bailian.openjudge.cn/practice/2737?lang=en_US
Accepted Code:
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner Scan = new Scanner(System.in);
BigInteger a = Scan.nextBigInteger();
BigInteger b = Scan.nextBigInteger();
System.out.println(a.divide(b));
}
}
高精度 * 单精度
题目链接:http://www.51nod.com/Challenge/Problem.html#problemId=1057
Accepted Code:
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner Scan = new Scanner(System.in);
int n = Scan.nextInt();
BigInteger s = BigInteger.ONE;
for (int i = 1; i <= n; i++)
s = s.multiply(new BigInteger(i + ""));
System.out.println(s);
}
}
高精度 / 单精度 & 高精度 % 单精度
题目链接:https://www.acwing.com/problem/content/796/
Accepted Code:
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner Scan = new Scanner(System.in);
BigInteger a = Scan.nextBigInteger();
int b = Scan.nextInt();
System.out.println(a.divide(new BigInteger(b + "")) + "\n" + a.remainder(new BigInteger(b + "")));
}
}
高精度幂取模
题目链接:https://ac.nowcoder.com/acm/contest/392/B
Accepted Code:
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner Scan = new Scanner(System.in);
int t = Scan.nextInt();
while (t-- > 0) {
BigInteger a = Scan.nextBigInteger();
BigInteger b = Scan.nextBigInteger();
BigInteger p = Scan.nextBigInteger();
System.out.println(a.modPow(b, p));
}
}
}