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. 关于判断StringBuffer是否为空

    对于String和StringBuffer来说,都是通过创建新的char value[]数组来达到字符串改变的操作的,只不过String是通过新创建String对象来达到目的, 而StringBuff ...

  2. JDBC API访问数据库的基本步骤。

    JDBC本质:官方定义了一套操作所有关系型数据库的规则(接口),各个数据库厂商实现这个接口,提供数据库驱动jar包. 我们可以使用这套接口(JDBC)编程,真正执行的代码是驱动jar包中的实现类. 任 ...

  3. 如何将EDM数据分类工作做的更加真善美

    众所周知,数据是互联网时代营销的决定性因素,数据的好坏关乎到营销能力的强弱,而细化到EDM行业中,数据细分变得极为重要,根据数据形态的不同,将会涉及到多种不同的细分方法,有效的利用这些方法,将会大大的 ...

  4. 由ES规范学JavaScript(二):深入理解“连等赋值”问题

    var foo={rzx:1} var bar =foo; foo.x=foo={rzx:100} console.log(foo.x) console.log(bar.x)   有这样一个热门问题: ...

  5. centOS7 flask项目布署

    先用1张图表示centOS布署flask的关键点,以及可能遇到的问题,及解决办法. 图片看不清,可以[下载]下来看,清晰度能够看清字 [目标] 局域网内,通过url可以访问flask编写的api 更新 ...

  6. msyql 计划任务 备份数据库

    用计划任务备份数据库 把exam库备份到家(home)目录下 [root@izuf66j5nlb2arg99viiuwz /]# mysqldump -u root -p exam > ~/ex ...

  7. Jmeter之简单控制器

    在很多情况下,我们 需要将多个请求放置在一起,但是没有逻辑上的操作,这个时候就可以使用简单控制器了. 如 :

  8. css让字体细长

    transform: scale(1,3); -ms-transform: scale(1,3); -webkit-transform: scale(1,3); -moz-transform: sca ...

  9. SAP简介

    1. 什么是SAP SAP的英文全名为System Application and Products in Data Processing.SAP既是公司名称,又是其产品的软件名称. 2. SAP的诞 ...

  10. linux打包

    1.打成tar包 sudo tar -zcf boot.tar /boot/ 2.打成zip包 sudo zip -r boot.zip ./*