Given three integers A, B and C in [−], you are supposed to tell whether A+B>C.

Input Specification:

The first line of the input gives the positive number of test cases, T (≤). Then T test cases follow, each consists of a single line containing three integers A, B and C, separated by single spaces.

Output Specification:

For each test case, output in one line Case #X: true if A+B>C, or Case #X: false otherwise, where X is the case number (starting from 1).

Sample Input:

3
1 2 3
2 3 4
9223372036854775807 -9223372036854775808 0

Sample Output:

Case #1: false
Case #2: true
Case #3: false
这个上面有2个Case是不能过的,在g++,但是在clang++可以过。
#include <iostream>
using namespace std;
int main(){
/**
依据算法笔记,以及其他人的博客,可知
可以进行溢出判断
1.即两个正数和为负数,溢出,比结果大
2.两个负数和为正数,溢出,比结果肯定小
3.一正一负直接比较
long long长度[-2**63,2**63)
*/
int T;long long a,b,c;
cin>>T;bool flag;//flag为true是true,false为false
for(int i=;i<T;i++){
cin>>a>>b>>c;
if(a>&&b>&&(a+b)<) flag=true;
else if(a<&&b<&&(a+b)>=) flag=false;
else{
if(a+b>c) flag=true;
else flag=false;
}
if(flag) cout<<"Case #"<<(i+)<<": true"<<endl;
else cout<<"Case #"<<(i+)<<": false"<<endl;
}
system("pause");
return ;
}

要想在g++过这个Case 可以使用用res存储的方式。至今不知道为啥不能直接比较,在g++上
#include <iostream>
using namespace std;
int main(){
/**
依据算法笔记,以及其他人的博客,可知
可以进行溢出判断
1.即两个正数和为负数,溢出,比结果大
2.两个负数和为正数,溢出,比结果肯定小
3.一正一负直接比较
long long长度[-2**63,2**63)
*/
int T;long long a,b,c,res;
cin>>T;bool flag;//flag为true是true,false为false
for(int i=;i<T;i++){
cin>>a>>b>>c;
res=a+b;
if(a>&&b>&&res<) flag=true;
else if(a<&&b<&&res>=) flag=false;
else{
if(res>c) flag=true;
else flag=false;
}
if(flag) cout<<"Case #"<<(i+)<<": true"<<endl;
else cout<<"Case #"<<(i+)<<": false"<<endl;
}
system("pause");
return ;
}

PAT Advanced 1065 A+B and C (64bit) (20 分)(关于g++和clang++修改后能使用)的更多相关文章

  1. PAT 甲级 1065 A+B and C (64bit) (20 分)(溢出判断)*

    1065 A+B and C (64bit) (20 分)   Given three integers A, B and C in [−], you are supposed to tell whe ...

  2. PAT (Advanced Level) Practice 1027 Colors in Mars (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1027 Colors in Mars (20 分) 凌宸1642 题目描述: People in Mars represent the c ...

  3. PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642 题目描述: A number that will ...

  4. PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) 凌宸1642 题目描述: With the 2010 FIFA World Cu ...

  5. PAT (Advanced Level) Practice 1005 Spell It Right (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1005 Spell It Right (20 分) 凌宸1642 题目描述: Given a non-negative integer N ...

  6. PAT (Advanced Level) Practice 1001 A+B Format (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1001 A+B Format (20 分) 凌宸1642 题目描述: Calculate a+b and output the sum i ...

  7. pat 甲级 1065. A+B and C (64bit) (20)

    1065. A+B and C (64bit) (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 HOU, Qiming G ...

  8. PAT 甲级 1065. A+B and C (64bit) (20) 【大数加法】

    题目链接 https://www.patest.cn/contests/pat-a-practise/1065 思路 因为 a 和 b 都是 在 long long 范围内的 但是 a + b 可能会 ...

  9. PAT A 1065. A+B and C (64bit) (20)

    题目 Given three integers A, B and C in [-263, 263], you are supposed to tell whether A+B > C. Inpu ...

随机推荐

  1. Linux shell - 除法保留小数点

    我想实现 举例:1/3=0.33得到0.33, 尝试过bc 只能得到.33,没有0了, linux 下的shell脚本,1和3是变量$a和$b,并能指定小数点后的位数, 方法1: $> res= ...

  2. Oracle开发:dba和sysdba的区别

    oracle dba和sysdba的区别如下: 1.dba是一种role对应的是对Oracle实例里对象的操作权限的集合,而sysdba是概念上的role是一种登录认证时的身份标识而已.而且,dba是 ...

  3. hibernate UML图

  4. jQuery-validate插件初级篇

    特别提示:本人博客部分有参考网络其他博客,但均是本人亲手编写过并验证通过.如发现博客有错误,请及时提出以免误导其他人,谢谢!欢迎转载,但记得标明文章出处:http://www.cnblogs.com/ ...

  5. 条形码(barcode)code128生成代码

    条形码(barcode)code128生成代码 很简单 多些这位兄弟https://bbs.csdn.net/topics/350125614 下面是我的DEMO 直接放到VS2005下面编译即可 # ...

  6. spring boot 整合saml2

    项目是国外的一位大神发布到githut上,这里只是对项目代码的分析与学习,也算是一种强化记忆 附上 githut地址:https://github.com/OpenConext/Mujina 项目分为 ...

  7. Openstack 实现技术分解 (2) 虚拟机初始化工具 — Cloud-Init & metadata & userdata

    目录 目录 前文列表 扩展阅读 系统环境 前言 Cloud-init Cloud-init 的配置文件 metadata userdata metadata 和 userdata 的区别 metada ...

  8. Spring Cloud的几个组件

    在微服务架构中,需要几个基础的服务治理组件,包括服务注册与发现.服务消费.负载均衡.断路器.智能路由.配置管理等,由这几个基础组件相互协作,共同组建了一个简单的微服务系统.一个简答的微服务系统如下图: ...

  9. java8 查找字符串中首次出现2次的字母

    利用java8的stream函数式编程进行处理 1.实现字母分离 map将整个字符串当成一个单词流来处理 Map<String[], Long> collect14 = Stream.of ...

  10. sql语句实现行转列的3种方法实例

    sql语句实现行转列的3种方法实例 一般在做数据统计的时候会用到行转列,假如要统计学生的成绩,数据库里查询出来的会是这样的,但这并不能达到想要的效果,所以要在查询的时候做一下处理,下面话不多说了,来一 ...