PAT——1011. A+B和C
给定区间[-231, 231]内的3个整数A、B和C,请判断A+B是否大于C。
输入格式:
输入第1行给出正整数T(<=10),是测试用例的个数。随后给出T组测试用例,每组占一行,顺序给出A、B和C。整数间以空格分隔。
输出格式:
对每组测试用例,在一行中输出“Case #X: true”如果A+B>C,否则输出“Case #X: false”,其中X是测试用例的编号(从1开始)。
输入样例:
4
1 2 3
2 3 4
2147483647 0 2147483646
0 -2147483648 -2147483647
输出样例:
Case #1: false
Case #2: true
Case #3: true
Case #4: false
package com.hone.basical; /**
* 分三个数组分别存放A B C 并且先将所有的数都存进去。
* 每次对应取出来,用减法做比较(目的是为了防止越界)然后做比较。
*/
import java.util.Scanner;
public class basicalLevel1011IsBigger2{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
long[]a = new long[T];
long[]b = new long[T];
long[]c = new long[T];
for(int i=0 ;i<T ;i++){
a[i] = sc.nextLong();
b[i] = sc.nextLong();
c[i] = sc.nextLong();
}
for(int i=0 ;i<T ;i++){
if(c[i]-b[i]<a[i]){
System.out.printf("Case #%d: true\n", i+1);
}
else{
System.out.printf("Case #%d: false\n", i+1);
}
}
}
}
PAT——1011. A+B和C的更多相关文章
- PAT 1011
1011. World Cup Betting (20) With the 2010 FIFA World Cup running, football fans the world over were ...
- PAT 1011 World Cup Betting
1011 World Cup Betting (20 分) With the 2010 FIFA World Cup running, football fans the world over w ...
- PAT 1011 A+B和C (15)(C++&JAVA&Python)
1011 A+B和C (15)(15 分) 给定区间[-2^31^, 2^31^]内的3个整数A.B和C,请判断A+B是否大于C. 输入格式: 输入第1行给出正整数T(<=10),是测试用例的个 ...
- pat 1011 World Cup Betting(20 分)
1011 World Cup Betting(20 分) With the 2010 FIFA World Cup running, football fans the world over were ...
- PAT 1011. A+B和C (15)
给定区间[-231, 231]内的3个整数A.B和C,请判断A+B是否大于C. 输入格式: 输入第1行给出正整数T(<=10),是测试用例的个数.随后给出T组测试用例,每组占一行,顺序给出A.B ...
- 浙大pat 1011题解
With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excite ...
- PAT 1011 A+B和C
https://pintia.cn/problem-sets/994805260223102976/problems/994805312417021952 给定区间[-2^31^, 2^31^]内的3 ...
- PAT 1011 World Cup Betting 查找元素
With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excite ...
- PAT 1011 World Cup Betting (20分) 比较大小难度级别
题目 With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly exc ...
随机推荐
- javascript之Array()数组函数讲解
Array()是一个用来构建数组的内建构造器函数.数组主要由如下三种创建方式: array = new Array() array = new Array([size]) array = new Ar ...
- spring实现固定时间定时器
此文章是基于 搭建Jquery+SpringMVC+Spring+Hibernate+MySQL平台 一. jar包介绍 1. spring-framework-4.3.4.RELEASE 的 lib ...
- Windows安装配置xampp
建议大家直接看原文 1.安装XAMPP 进入https://www.apachefriends.org/zh_cn/index.html页面下载XAMPP 2 3.打开xampp控制版 4.修改apa ...
- dotnet watch+vs code提升asp.net core开发效率
在园子中,已经又前辈介绍过dotnet watch的用法,但是是基于asp.net core 1.0的较老版本来讲解的,在asp.net core 2.0的今天,部分用法已经不太一样,所以就再写一篇文 ...
- 002服务提供者Eureka
1.POM配置 和普通Spring Boot工程相比,仅仅添加了Eureka.Spring Boot Starter Actuator依赖和Spring Cloud依赖管理 <dependenc ...
- ERROR:Tried to register widget id ==basemapGalleryDiv but that id is already registered解决办法
在ArcGIS Server开发中,遇到DIV已经被注册的情况,不能对原DIV内容进行更新.这里需要调用Dojo的destroyRecursive()方法,逐个销毁该Widget下的子元素及其后代元素 ...
- SQL Server ->> 时间函数: EOMONTH, DATEFROMPARTS, TIMEFROMPARTS, DATETIMEFROMPARTS, DATETIMEOFFSETFROMPARTS
上面几个函数都是SQL Server 2012新增的时间函数. EOMONTH 返回传入时间的月结束日,返回数据类型为DATE SELECT EOMONTH(GETDATE()) 结果为 DATEFR ...
- 【Leetcode】【Medium】Letter Combinations of a Phone Number
Given a digit string, return all possible letter combinations that the number could represent. A map ...
- [翻译] iOS开发工具的介绍(第一部分)
IOS DEVELOPMENT TIPS & TRICKS - PART I http://blog.trifork.com/2013/12/19/ios-development-tips-t ...
- ieHTTPHeaders使用方法
在http://www.blunck.se/iehttpheaders.html下载软件打开IE浏览器查看-->浏览器栏-->ieHTTPHeaders可以查看httpheader tra ...