每日一练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 是一个免费的工具.它可以用来准备和管理数据模型:包括链接各种数据:做数据清洗:定义关系:定义度量值和层级关系:应用 ...
随机推荐
- SHA-256算法和区块链原理初探
组内技术分享的内容,目前网上相关资料很多,但读起来都不太合自己的习惯,于是自己整理并编写一篇简洁并便于(自己)理解和分享的文章. 因为之前对密码学没有专门研究,自己的体会或理解会特别标注为" ...
- 爬虫 2 XPath 和 pyquery
XPath 1.常用规则 表达式 描述 nodename 选取此节点的所有子节点 / 从当前节点选取直接子节点 // 从当前节点选取子孙节点 . 选取当前节点 .. 选取当前节点的父节点 @ 选 ...
- Arthas的基础学习
下载与安装 wget https://alibaba.github.io/arthas/arthas-boot.jar java -jar arthas-boot.jar 启动 查看启动的帮助信息: ...
- EasyUIDataGrid去掉垂直滚动条
打开jquery.easyui.min.js 搜索到var _64f=wrap.width();这行代码 修改为ar _64f=wrap.width()+20;即可 另外在前台datagrid的hei ...
- C语言作业04-数组
1.本章学习总结 1.1思维导图 1.2本章学习体会及代码量学习体会 1.2.1学习体会 通过本章的学习,学会了几种用于循环的语句,能够利用循环解决复杂的问题,但对于几种循环的使用并不熟练,其中对于c ...
- OOP的概念和基础特性
OOP是面对对象程序设计,是一种程序设计范型,同时也是一种程序开发方法.它将对象作为程序的基本单元,将程序和数据封装其中,以提高程序的复用性.灵活性.可扩展行. OOP的核心思想是对象.封装.可复用性 ...
- pandas,对dataFrame中某一个列的数据进行处理
背景:dataFrame的数据,想对某一个列做逻辑处理,生成新的列,或覆盖原有列的值 下面例子中的df均为pandas.DataFrame()的数据 1.增加新列,或更改某列的值 df[&qu ...
- pandas中的时间序列基础
重要的数据形式时间序列 datetime以毫秒形式存储日期和时间 now = datetime.now() now datetime.datetime(2018, 12, 18, 14, 18, 27 ...
- d3.js svg中 g 标签问题一览
svg 中的g标签, 算是比较特殊 1 没有x y属性 2 没有width height 属性 3 不能fill 4 .... g标签基本只管分组问题, 其他功能一概不提供 要解决这些问题, 直接在g ...
- Spring常用注解总结(3)
@Configuration 表示该类为"配置类",可替换xml配置文件.与@Component不同的是,@Configuration会生成CGLIB代理class. @Targe ...