HDOJ 1002 A + B Problem II

简介: HDOJ 1002 A + B Problem II

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.math.BigDecimal;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t=1;
        while(n-->0){
            if(t==1){
            }else{
                System.out.println();
            }
            BigDecimal a = sc.nextBigDecimal();
            BigDecimal b = sc.nextBigDecimal();
            BigDecimal c = a.add(b);
            System.out.println("Case "+t+":");
            System.out.println(a+" + "+b+" = "+c);
            t++;
        }
    }
}
目录
相关文章
hdoj 2089 不要62
这题数据量相对比较小,可以暴力打表解决。不过我这里用数位dp 刚开始学数位dp,参考了别人的代码。
55 0
HDOJ 1412 {A} + {B}
HDOJ 1412 {A} + {B}
117 0
HDOJ 2034 人见人爱A-B
HDOJ 2034 人见人爱A-B
126 0
HDOJ 1323 Perfection(简单题)
Problem Description From the article Number Theory in the 1994 Microsoft Encarta: “If a, b, c are integers such that a = bc, a is called a...
847 0
HDOJ的题目分类
模拟题, 枚举 1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 1049 1050 1057 1062 1063 1064 1070 1073 ...
1827 0
HDOJ 2802 F(N)
Problem Description Giving the N, can you tell me the answer of F(N)? Input Each test case contains a single integer N(1
718 0
|
测试技术
HDOJ 2033 人见人爱A+B
Problem Description HDOJ上面已经有10来道A+B的题目了,相信这些题目曾经是大家的最爱,希望今天的这个A+B能给大家带来好运,也希望这个题目能唤起大家对ACM曾经的热爱。
959 0
HDOJ 2004 成绩转换
Problem Description 输入一个百分制的成绩t,将其转换成对应的等级,具体转换规则如下: 90~100为A; 80~89为B; 70~79为C; 60~69为D; 0~59为E; Input 输入数据有多组,每组占一行,由一个整数组成。
895 0
|
Java
HDOJ 1234
开门人和关门人 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7142    Accepted Submission(s): 3656 Problem Description 每天第一个到机房的人要把门打开,最后一个离开的人要把门关好。
782 0