每日一练ACM 2019.04.13
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的更多相关文章
- 每日一练ACM 2019.04.14
2019.4.14 第1001题:Sum Problem Problem DescriptionHey, welcome to HDOJ(Hangzhou Dianzi University Onli ...
- 每日一练ACM 2019.0416
2019.04.16 Problem Description Your task is to Calculate the sum of some integers. Input Input ...
- 每日一练ACM 2019.0422
Problem Description 根据输入的半径值,计算球的体积. Input 输入数据有多组,每组占一行,每行包括一个实数,表示球的半径. Output 输出对应的球的体积,对于每组输 ...
- 每日一练ACM 2019.0418
Problem Description 输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离. Input 输入数据有多组,每组占一行,由4个实数组成,分别表示x1,y1,x2,y2 ...
- 每日一练ACM 2019.0417
Problem Description 给定两个正整数,计算这两个数的最小公倍数. Input 输入包含多组测试数据,每组只有一行,包括两个不大于1000的正整数. Output 对于每个测试 ...
- 每日一练ACM
2019.04.15 第1000题:A+B Problem Problem DescriptionCalculate A + B. InputEach line will contain two in ...
- 2019.04.13 python基础
第一节 主要讲python背景 没什么要注意的 了解记住概念就好 python官网 python.org 自带shell 可以运行python代码 在IDLE中怎么运行代码 新建文本 ...
- HTML5每日一练之figure新标签的应用
igure元素是一种元素的组合,可带有标题(可选).figure标签用来表示网页上一块独立的内容,将其从网页上移除后不会对网页上的其他内容产生影响.figure所表示的内容可以是图片.统计图或代码示例 ...
- PowerBI更新2019/04 - 解决方案架构 - PowerBI Solution Architecture(一图胜万字!)
Power BI 架构图 (2019/04) 1) Power BI Desktop 是一个免费的工具.它可以用来准备和管理数据模型:包括链接各种数据:做数据清洗:定义关系:定义度量值和层级关系:应用 ...
随机推荐
- jdk-8u181-docs.chm -- 制作时间2018年8月12日
为了方便查阅,自己做了一个JDK8的chm文件:jdk-8u181-docs.chm 密码: g675 chm制作工具 :chmwriter 目录:
- 模仿input闪烁光标
模仿闪烁的光标 <span class="cursor-blink"> </span> 样式代码: .cursor-blink { display: inl ...
- Codeforces Round #436 C. Bus
题意:一辆车在一条路上行驶,给你路的总长度a,油箱的容量b,加油站在距离起点的距离f,以及需要走多少遍这条路k(注意:不是往返) 问你最少加多少次油能走完. Examples Input 6 9 2 ...
- Linux-01
Linux各目录的作用 /bin/ 存放系统命令的目录,普通用户和超级用户都可以执行.不过放在/bin下的命令在单用户模式下也可以执行 /sbin/ 保存和系统环境设置相关的命令,只有超级用户可以使用 ...
- selenium java 浏览器操作
环境搭建 selenium 2.53 selenium-java-2.53.0.jar selenium-java-2.53.0-srcs.jar 原代码包 拷贝的工程lib下,做build path ...
- iOS获取崩溃日志
重要提示: 此文档不再更新.有关Apple SDK的最新信息,请访问文档网站. 来源: https://developer.apple.com/library/archive/qa/qa1747/_ ...
- 【LeetCode刷题系列 - 003题】Longest Substring Without Repeating Characters
题目: Given a string, find the length of the longest substring without repeating characters. Example 1 ...
- 阿里云SLB负载均衡与使用SSL域名证书
阿里云SLB负载均衡与使用SSL证书 1.购买两台ECS服务器,这就是后台服务器,在这两个服务器上面部署你的网站,注意网站的端口要一样:比如都是 88. 2.在阿里云控制台的菜单里找到 负载均衡,创建 ...
- Quartz.Net进阶之五:TriggerListener 、JobListener 和 SchedulerListener
一.介绍 今天开始学习监听器,就是 Listener,在Quartz.Net 中,主要包含3类的监听器,主要内容包括:TriggerListener .JobListener 和 SchedulerL ...
- ASP.NET Core 添加NLog日志支持(VS2015update3&VS2017)
1.创建一个新的ASP.NET Core项目 2.添加项目依赖 NLog.Web.AspNetCore 3.在项目目录下添加nlog.config文件: <?xml version=" ...