Problem Description
E_star由于在上次考试中取得了很好的成绩他开始骄傲起来,此时von看不下去了,于是就想找他的岔,他把E_star叫来说最近一道A+B编程题目不会,想要让同是计算机专业的E_star来帮他解答,E_star由于考试后的骄傲心理,二话没说结一口答应了,等到von用qq把题目要求发给E_star的时候他傻眼了。自己根本就不会,其实von知道他不会故意整他的。他为了留住面子只好请他最好的朋友你帮他解答了。这下知道骄傲的后果了吧。
Input
题目有多组数据,处理到文件结束。输入的第一行包含一个数T代表测试组数;
接下来有T行,每行有两个数A,B;
Output
对于每一组数据输出的第一行是"Case #:"代表第几组数据;
接下来一行是A+B=以及A+B的和。
具体输出格式见样例。
Sample Input
2
1 2
112233445566778899 998877665544332211
Sample Output
Case 1:
1+2=3
Case 2:
112233445566778899+998877665544332211=1111111111111111110
Hint
Source
E_star
思路:
与C和C++处理大数时所用的大数模拟不同,我们可以直接使用JAVA语言内置的BigInteger类进行大数的处理。详情可以参照下面的博客链接。
BigInteger详解
package cn.edu.sdut.acm;
import java.math.BigInteger;
import java.util.*;
import java.lang.StringBuffer;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int t = sc.nextInt();
for (int i = 1; i <= t; i++) {
String str1 = sc.next();
String str2 = sc.next();
BigInteger num1 = new BigInteger(str1);
BigInteger num2 = new BigInteger(str2);
System.out.printf("Case %d:", i);
System.out.println();
System.out.println(num1+"+"+num2+"="+num1.add(num2));
}
}
}
}