Problem Description
I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.
Input
The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line consists of two positive integers, A and B. Notice that the integers are very large, that means you should
not process them by using 32-bit integer. You may assume the length of each integer will not exceed 1000.
Output
For each test case, you should output two lines. The first line is "Case #:", # means the number of the test case. The second line is the an equation "A + B = Sum", Sum means the result of A + B. Note there are some spaces int the
equation. Output a blank line between two test cases.
Sample Input
2
1 2
112233445566778899 998877665544332211
Sample Output
Case 1:
1 + 2 = 3
Case 2:
112233445566778899 + 998877665544332211 = 1111111111111111110
import java.util.*;
import java.math.*;
public class Main3 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=Integer.parseInt(sc.next());
for(int i=0;i<t;i++){
BigInteger a=new BigInteger(sc.next());
BigInteger b=new BigInteger(sc.next());
BigInteger c=a.add(b);
System.out.println("Case "+(i+1)+":");
System.out.println(a+" "+"+"+" "+b+" "+"="+" "+c);
if(i!=t-1)
System.out.println();
}
}
}
分享到:
相关推荐
ACM HDU 2000->2099 解题报告 ACM HDU 2000->2099 解题报告 ACM HDU 2000->2099 解题报告
大数相加
HDU 1010-2500解题报告,ACMer可以借鉴一下
hdu2000-2014ac代码,虽然只有几道,但都是简单的
hdu-acm源代码(上百题)hdu-acm源代码、hdu-acm源代码hdu-acm源代码
ACM入门的课件适合于那些想要学习的ACM,提高自己编程能力的。
杭州电子科技大学online judge (hdu)第十一卷 2000 - 2099 题目集 doc 格式的,希望大家喜欢!
ACM题库,一些题目和答案,以及解题报告,传上来共享
解题报告|ACM|程序设计参考程序以及题目的分析
ACM程序设计题目分析以及AC的源码
最精准的答案(本人做对的题目拿上来给大家呈现)!不要忘记是C++编的
杭电OnlineJudge 200-2099的解题报告
我去年暑假花了5天,把杭电ACM网站上2000到2099这100道题全AC了,又花了10来天精心写解题报告。 里面包括题目、解题思路、编程技巧以及参考源码。所有代码都是使用C/C++写的。 最近整理资料时无意间发现,打包...
算法-数塔(HDU-2084).rar
HDU的1250,主要是利用高精度加法,但是代码有点繁琐,效率不是很高
HDU 里面的2000~2099道题目的源码。谢谢支持
杭电ACM2000-2099题的解题报告