HDOJ1002: A + B Problem II
来源:互联网 发布:驱动精灵网络连接错误 编辑:程序博客网 时间:2024/06/06 02:54
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
21 2112233445566778899 998877665544332211
Sample Output
Case 1:1 + 2 = 3Case 2:112233445566778899 + 998877665544332211 = 1111111111111111110
Java Code:
import java.math.BigInteger;import java.util.Scanner;public class Main {public static void main(String[] args){int count=1;Scanner sc=new Scanner(System.in);int T=sc.nextInt();while(T-->0){String str1=sc.next();String str2=sc.next();BigInteger a=new BigInteger(str1);BigInteger b=new BigInteger(str2);System.out.println("Case "+count+":");System.out.println(a+" + "+b+" = "+a.add(b));count++;if(T!=0){System.out.println();}}}}
- HDOJ1002 A + B Problem II
- HDOJ1002 A + B Problem II
- HDOJ1002: A + B Problem II
- hdoj1002--A + B Problem II
- hdoj1002 A + B Problem II
- HDOJ1002 A + B Problem II
- hdoj1002 A + B Problem II
- HDOJ1002 A + B Problem II
- hdoj1002A + B Problem II
- HDOJ1002 A + B Problem II(大数)
- HDOJ1002 A + B Problem II(大数加法)
- [HDOJ1002] A + B Problem II 高数度加法运算
- 【hdoj1002】 A + B Problem II(模拟加法)
- hdoj1002 A + B Problem II 初学大数相加
- HDOJ1002题A + B Problem II,2个大数相加
- hdoj1002(A+B problem II 大数相加 c语言
- java练习第二天hdoj1002-A + B Problem II【大数】
- hdoj1002 A + B Problem II(简单的大数处理)
- 少年强则国强
- UIBezierPath 的使用介绍
- JEECG Framework 3.4.1 beta 版本发布
- C3P0详细配置
- 从朴素的字符串匹配算法到KMP算法
- HDOJ1002: A + B Problem II
- 开始自己的五年计划
- 时间处理类
- IOS开发-画线画图
- Codeforces Round #212 (Div. 2) C
- ubuntu 12.04 安装 boost 失败,have unmet dependencies,held broken packages 问题
- 薪资
- UML中几种类间关系:继承、实现、依赖、关联、聚合、组合的联系与区别
- MFC动态添加按钮以及消息响应