2019.04.13

第1002题:A+B Proble Ⅱ

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

题目解析:
输入的第一行:T为实例的数量,再输入T行的例子,每行有2个正整数(他们很大,所以不能用32位的整数来表示),要求计算两个数的和并输出,保证输入的每个整数的长度不超过1000。

解:

package Acm;

import java.math.BigInteger;
import java.util.Scanner; public class test3 { public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input=new Scanner(System.in);
int n=input.nextInt();
for(int i=0;i<n;i++)
{
BigInteger a=input.nextBigInteger();
BigInteger b=input.nextBigInteger();
if(i==n-i)
{
System.out.print("case"+(i+1)+"\r\n"+a+"+"+b+"="+a.add(b)); }
else
{
System.out.println("case"+(i+1)+"\r\n"+a+"+"+b+"="+a.add(b));
}
}
} }

每日一练ACM 2019.04.13的更多相关文章

  1. 每日一练ACM 2019.04.14

    2019.4.14 第1001题:Sum Problem Problem DescriptionHey, welcome to HDOJ(Hangzhou Dianzi University Onli ...

  2. 每日一练ACM 2019.0416

    2019.04.16     Problem Description Your task is to Calculate the sum of some integers.   Input Input ...

  3. 每日一练ACM 2019.0422

    Problem Description 根据输入的半径值,计算球的体积.   Input 输入数据有多组,每组占一行,每行包括一个实数,表示球的半径.   Output 输出对应的球的体积,对于每组输 ...

  4. 每日一练ACM 2019.0418

    Problem Description 输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离.   Input 输入数据有多组,每组占一行,由4个实数组成,分别表示x1,y1,x2,y2 ...

  5. 每日一练ACM 2019.0417

    Problem Description 给定两个正整数,计算这两个数的最小公倍数.   Input 输入包含多组测试数据,每组只有一行,包括两个不大于1000的正整数.   Output 对于每个测试 ...

  6. 每日一练ACM

    2019.04.15 第1000题:A+B Problem Problem DescriptionCalculate A + B. InputEach line will contain two in ...

  7. 2019.04.13 python基础

    第一节    主要讲python背景  没什么要注意的  了解记住概念就好 python官网  python.org  自带shell  可以运行python代码 在IDLE中怎么运行代码 新建文本  ...

  8. HTML5每日一练之figure新标签的应用

    igure元素是一种元素的组合,可带有标题(可选).figure标签用来表示网页上一块独立的内容,将其从网页上移除后不会对网页上的其他内容产生影响.figure所表示的内容可以是图片.统计图或代码示例 ...

  9. PowerBI更新2019/04 - 解决方案架构 - PowerBI Solution Architecture(一图胜万字!)

    Power BI 架构图 (2019/04) 1) Power BI Desktop 是一个免费的工具.它可以用来准备和管理数据模型:包括链接各种数据:做数据清洗:定义关系:定义度量值和层级关系:应用 ...

随机推荐

  1. celery (二) task调用

    调用 TASK 基础 task 的调用方式有三种: 类似普通函数的调用方式, 通过 __calling__ 调用 ,类似 function() 通过 apply_async() 调用,能接受较多的参数 ...

  2. python基础之语句字符串

    python的种类: jpython                 java写的python ironpython            c#写的python cpython             ...

  3. ES6你不知道的let关键字及变量的提升

    一.JavaScript变量创建到访问赋值的过程 创建 create/declare 初始化 initialize 赋值 assign 1.函数的提升 // 函数这种变量声明,首先会创建变量,再初始化 ...

  4. CR--同事分享学习

    1.持续发布是什么? 频繁地将软件的新版本,交付给质量团队或者用户,以供评审. 2.对接持续发布需要具备什么条件? 1)  测试自动化程度较高,持续发布的终态是不需要人工介入 2)  做到持续集成,持 ...

  5. 查询sqlserver数据库表的记录数

    SELECT a.name, b.rows FROM sysobjects AS a INNER JOINsysindexes AS b ON a.id = b.idWHERE (a.type = ' ...

  6. 国内安装helm

    helm repo remove stable helm repo add stable https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts ...

  7. 大数据学习笔记5 - Spark

    Spark是一个基于内存计算的大数据并行计算框架.所以,Spark并不能完全替代Hadoop,主要用于替代Hadoop中的MapReduce计算模型. 在实际应用中,大数据处理无非是以下几个类型: 复 ...

  8. MAC终端如何使用rar和unrar

    一.MAC具体安装见下面两个博客分享: Homebrew介绍和使用:https://www.jianshu.com/p/de6f1d2d37bf Mac 压缩 / 解压缩工具解决方案:https:// ...

  9. springboot添加自定义注解

    spring拦截器是基于动态代理,注解就是拦截器,所以关于动态代理需要注意的坑,注解同样要注意. 1.创建注解类 /** * @Target 此注解的作用目标,括号里METHOD的意思说明此注解只能加 ...

  10. python note 14 其他函数及递归应用

    1.repr用法 print("你好") # 用户看着舒服 print(repr("你好")) # 真实的字符串表示形式(正式的)print("我叫% ...