A + B Problem II

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 313689 Accepted Submission(s):
60742

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.BigInteger;
import java.text.Bidi;
import java.util.Scanner;
public class Main1002 {
public static void main(String[] args) {
Scanner cin=new Scanner(System.in);
while(cin.hasNext()){
int n=cin.nextInt();
int t=0;
while(n-->0){
BigInteger b=cin.nextBigInteger();
BigInteger c=cin.nextBigInteger();
BigInteger d=new BigInteger("0");
d=b.add( c);
System.out.println("Case"+" "+(++t)+":");
System.out.println(b+" "+"+"+" "+c+" "+"="+" "+d);
if(n!=0)
System.out.println();
}
}

}

}

感觉用java 做大数相加的这个题好简单呀

hdu1002大数相加的更多相关文章

  1. HDU-1002.大数相加(字符串模拟)

    本题大意:给出两个1000位以内的大数a 和b,让你计算a + b的值. 本题思路:字符串模拟就能过,会Java的大佬应该不会点进来...... 参考代码: #include <cstdio&g ...

  2. HDU1002 大数相加

    #include <iostream> #include <iostream> #include <iomanip> #include<string> ...

  3. hdu1002 大数相加问题

    这个题对于 几个月前的我简直是噩梦  好在磕磕绊绊终于写出来了 由于自己的问题  还被巨巨嘲讽了 1 1.#include<stdio.h> 2 2.#include<string. ...

  4. hdu acm-1047 Integer Inquiry(大数相加)

    Integer Inquiry Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  5. 用字符串模拟两个大数相加——java实现

    问题: 大数相加不能直接使用基本的int类型,因为int可以表示的整数有限,不能满足大数的要求.可以使用字符串来表示大数,模拟大数相加的过程. 思路: 1.反转两个字符串,便于从低位到高位相加和最高位 ...

  6. 随机数组&大数相加

    随机生成10个数,填充一个数组,然后用消息框显示数组内容,接着计算数组元素的和,将结果也显示在消息框中 一,      设计思路: 先生成随机数数组,再将数组保存在一个字符串中,然后将数组各数字加和, ...

  7. java-两个大数相加

    题目要求:用字符串模拟两个大数相加. 一.使用BigInteger类.BigDecimal类 public static void main(String[] args) { String a=&qu ...

  8. POJ 1503 Integer Inquiry(大数相加,java)

    题目 我要开始练习一些java的简单编程了^v^ import java.io.*; import java.util.*; import java.math.*; public class Main ...

  9. 杭电ACM(1002) -- A + B Problem II 大数相加 -提交通过

    杭电ACM(1002)大数相加 A + B Problem II Problem DescriptionI have a very simple problem for you. Given two ...

随机推荐

  1. web storm使用和配置

    官网:http://www.jetbrains.com/webstorm/ webStorm,File=>setting=>JavaScript-Libraries How WebStor ...

  2. 如何查看自己运行ubuntu是32位还是64位

    当安装ubuntu在pc上,不推荐在32位pc安装64位操作系统,64位pc安装32位操作系统 方法/步骤 按ctrl+shift+t 快捷键,打开终端,输入sudo uname --m ,按下ent ...

  3. function(a)

    问题:  问个初级的问题int a = 8;function(a);这里在function中的a值是引用a内存中的数据,还是新开辟内存后将a的值赋值到新内存供函数调用.  回答: int a = 8; ...

  4. hadoop2.2编程:使用MapReduce编程实例(转)

    原文链接:http://www.cnblogs.com/xia520pi/archive/2012/06/04/2534533.html 从网上搜到的一篇hadoop的编程实例,对于初学者真是帮助太大 ...

  5. 逻辑运算符&& 用法解释

    A&&B 首先判断A,A成功然后判断B:A不成功则结束判断,返回false;

  6. clone Control event handlers at run time

    var btn2 =newButton(); btn2.Text= btn1.Text; btn2.size = btn1.size; To clone all events of any WinFo ...

  7. HDOJ 2167 Pebbles (状态压缩dp)

    题意:给你一个n*n的矩阵,让你从矩阵中选择一些数是的他们的和最大,规则是:相邻的两个数不能同时取,位置为(i,j)的数与(i+1,j),(i-1,j),(i,j+1),(i,j-1),(i+1,j+ ...

  8. POJ 1200 Crazy Search

    思路:利用Karp-Rabin算法的思想,对每个子串进行Hash,如果Hash值相等则认为这两个子串是相同的(事实上还需要做进一步检查),Karp-Rabin算法的Hash函数有多种形式,但思想都是把 ...

  9. leecode single numer

    http://www.acmerblog.com/leetcode-single-number-ii-5394.html acm之家的讲解总是那么到位 public class Solution { ...

  10. 如何通过Visual Studio发布Azure应用程序

    发布 Azure 云服务 使用 Azure Tools for Visual Studio,可以直接从 Visual Studio 将云服务发布到 Azure. 在发布 Azure 云服务之前,必须已 ...