题解 | #高精度整数加法#
高精度整数加法
https://www.nowcoder.com/practice/49e772ab08994a96980f9618892e55b6
import java.util.Scanner;
import java.math.BigInteger;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str1 = sc.nextLine();
String str2 = sc.nextLine();
BigInteger b1 = new BigInteger(str1);
BigInteger b2 = new BigInteger(str2);
BigInteger add = b1.add(b2);
System.out.println(add);
}
}
查看10道真题和解析