A + B Problem II

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.io.BufferedInputStream;
import java.math.BigInteger;
import java.util.Scanner; public class Main { public static void main(String[] args) {
// TODO 自动生成的方法存根
Scanner str = new Scanner(System.in);
int T;
T=str.nextInt();
int i=1; for(i=1;i<=T;i++)
{
BigInteger a=str.nextBigInteger();
BigInteger b=str.nextBigInteger();
System.out.println("Case "+i+":");
System.out.println(a+" + "+b+" = "+a.add(b));
if(i<T)
{
System.out.println("");
} } } }

JAVA 大数 A+B问题的更多相关文章

  1. java大数

    java大数还是很好用的! 基本加入: import java.math.BigInteger; import jave.math.BigDecimal; 分别是大数和大浮点数. 首先读入可以用: S ...

  2. JAVA大数运算

    java大数是个好东西,用起来方便,代码短. 代码如下: import java.util.*; import java.math.*; public class Main { public stat ...

  3. java大数总结【转】

    java大数(2013长春网络赛)--hdu4762总结一下:1.java提交类要写Main.2.读取大数. Scanner read=new Scanner(System.in); BigInteg ...

  4. HDU5047Sawtooth(java大数)

    HDU5047Sawtooth(java大数) 题目链接 题目大意:在一个矩形内画n个"M".问如何画可以把这个矩形分成最多的区域. 给出这个区域的数目. 解题思路:最好的方式就是 ...

  5. JAVA大数类

    JAVA大数类api http://man.ddvip.com/program/java_api_zh/java/math/BigInteger.html#method_summary 不仅仅只能查J ...

  6. HDU4762(JAVA大数)

    Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  7. ZOJ3477&JAVA大数类

    转:http://blog.csdn.net/sunkun2013/article/details/11822927 import java.util.*; import java.math.BigI ...

  8. 多校第五场 归并排序+暴力矩阵乘+模拟+java大数&amp;记忆化递归

    HDU 4911 Inversion 考点:归并排序 思路:这题呀比赛的时候忘了知道能够用归并排序算出逆序数,可是忘了归并排序的实质了.然后不会做-- 由于看到题上说是相邻的两个数才干交换的时候.感觉 ...

  9. 收藏的一段关于java大数运算的代码

    收藏的一段关于java大数运算的代码: package study_02.number; import java.math.BigDecimal; import java.math.BigIntege ...

  10. java大数判断相等

    java大数判断相等: 1.equals()方法2.compareTo()方法区别:2.00与2.0 equals()方法判断不等,compareTo()方法判断相等,科学的说法可以看java api ...

随机推荐

  1. CSS 伪类与伪元素

    CSS的元素选择器除了根据id(#).class(.).属性([ ])选取元素以外,还有很重要的一类,就是根据元素的特殊状态来选取元素.它们就是伪类和伪元素.跟id选择器.类选择器.属性选择器以及派生 ...

  2. 1.sql简介

    在总结sql语句前,说点无聊的哈哈 SQL 是用于访问和处理数据库的标准的计算机语言. SQL 能做什么? SQL 面向数据库执行查询 SQL 可从数据库取回数据 SQL 可在数据库中插入新的记录 S ...

  3. c# 获取非托管指针长度

    public List<string> GetPDFValues() { List<string> strs = new List<string>(); unsaf ...

  4. IOException while loading persisted sessions: java.io.EOFException

    运行eclipse启动服务器的时候,出现了IOException while loading persisted sessions: java.io.EOFException报错.本以为是代码修改出现 ...

  5. HackFifteen 移除背景以提升Activity启动速度

    1.概要:     移除窗口默认背景是提升应用程序启动速度的一个简单技巧.判断是否需要移除背景的原则很简单:如果应用程序界面需要 占据窗口100%的控件,就需要将windowBackground属性设 ...

  6. Graphics 小记

    1.切图 drowg.DrawImage(productImg1, new System.Drawing.Rectangle(30, 30, 300, 300), new System.Drawing ...

  7. ICallbackEventHandler使用

    后端:页面需继承ICallbackEventHandler protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack ...

  8. sql server 简单语句整合

    1.去重distinct , group by select distinct userid,username from 表名 select userid,username from 表名 group ...

  9. 使用VS Code开发C++

    1. 参考/转载 vs code进行c/c++开发 VSCode 的第一个C++程序(windows)[更新2018.10.28] 2. C++开发相关插件(扩展商店中直接搜索) 至少要装C/C++. ...

  10. Windows实用功能

    查看程序crash日志:"Computer Management"-"System Tools"-"Event Viewer"-" ...