HDOJ 1002 A + B Problem II
2016-02-02 17:18
357 查看
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
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++; } } }
相关文章推荐
- [Unity3D学习]Unity代码热更新 源码下载
- HDOJ 1002 A + B Problem II
- mapreduce 自定义数据类型的简单的应用
- 设置EntityFramework 在开发时自动更新数据库
- python 多线程笔记(1)-- 概念
- 【ASP.NET Identity系列教程(一)】ASP.NET Identity入门
- 3.Java 加解密技术系列之 SHA
- 工作线程中更新UI
- java特种兵读书笔记(5-3)——并发之原子性与锁
- 第一行代码2.5-活动的启动模式
- Androidx学习笔记(37)--- 网络提交数据的方式--POST方式提交数据
- C# GDI+绘制双曲线
- JavaScript+html5 canvas实现本地截图教程
- SDL2源代码分析7:显示(SDL_RenderPresent())
- Win7旗舰版系统开机屏幕提示press F1 to continue的解决方法
- Sphinx配置搜索
- SDL2源代码分析6:复制到渲染器(SDL_RenderCopy())
- Androidx学习笔记(36)---网络提交数据的方式--GET方式提交数据
- can't load library 'libstdc++.so.6'
- [Unity3D学习]Unity代码热更新解决方案测试结果总结