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 ...
随机推荐
- mysql自定义变量
mysql可以实现自定义变量,使用方式非常简单,代码如下: SELECT @i:=@i + 1 // 查询变量,值+1 FROM () i // 声明变量,初始值为0 如果有多条数据,那么这个变量就会 ...
- OOP 第一章作业总结
程序设计结构分析 类图分析 第一次作业 由于第一次作业完成的功能比较简单,而且出于对面向对象设计理念不熟悉(其实现在也不是很熟悉,逃),整个程序设计的非常简单.通过类图(见下)可以看出,程序只有两个类 ...
- POJ 2955 Brackets 区间DP 最大括号匹配
http://blog.csdn.net/libin56842/article/details/9673239 http://www.cnblogs.com/ACMan/archive/2012/08 ...
- Windows下RSA密钥生成工具openssl
下载openssl.zip 1. 生成原始 RSA私钥文件 private_key.pem openssl genrsa -out private_key.pem 1024 2. 将原始 RSA私钥转 ...
- 官网下载apache服务器并运行
1.打开官网 https://httpd.apache.org/ 2.找到下载位置,比如我们要下载2.x版本 点击download,在下一页找到 Files for Microsoft Wi ...
- PHP框架中.htaccess文件作用
1..htaccess文件使用前提 .htaccess的主要作用就是实现url改写,也就是当浏览器通过url访问到服务器某个文件夹时,作为主人,我们可以来接待这个url,具体地怎样接待它,就是此文件的 ...
- Android热修复 Dex注入实现静默消灭bug
当app上线后发现紧急bug,如果重新发布版本周期比较长,并且对用户体验不好,此时热修复就派上用场了.热修复就是为紧急bug而生,能够快速修复bug,并且用户无感知.针对热修复,阿里系先后推出AndF ...
- QT 定时执行某个函数,隐藏某个控件
QTimer::singleShot(3000, this, SLOT(slotHideFinishedLabel())); // 这里是一个3秒定时器, 且只执行一次. #include " ...
- arcgis 线段合并
对于上面这种这种有一个字段相同的 线段,使用 使用后生成的矢量如下
- PHP 调用web service接口(.net开发的接口)
实例代码1: try { $this->soapClientObj = new SoapClient(self::URL . '?wsdl', array('connection_timeout ...