题目描述
谷学长有一个非常简单的问题给你,给你两个整数A和B,你的任务是计算A+B。
输入描述
输入的第一行包含一个整数T(T<=20)表示测试实例的个数,然后2*T行,分别表示A和B两个正整数。注意整数非常大,那意味着你不能用32位整数来处理。你可以确定的是整数的长度不超过1000。
输出描述
对于每一个样例,你应该输出两行,第一行是"Case #:",#表示第几个样例,第二行是一个等式"A+B=Sum",Sum表示A+B的结果。注意等式中有空格。
样例输入
2 1 2 112233445566778899 998877665544332211
样例输出
Case 1: 1 + 2 = 3 Case 2: 112233445566778899 + 998877665544332211 = 1111111111111111110
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int T = scanner.nextInt();
int x = 1;
scanner.nextLine(); // 读取换行符
while (T-- > 0) {
String a = scanner.nextLine();
String b = scanner.nextLine();
BigInteger numA = new BigInteger(a);
BigInteger numB = new BigInteger(b);
BigInteger sum = numA.add(numB);
System.out.println("Case " + x + ":");
System.out.println(a + " + " + b + " = " + sum);
x++;
}
}
}