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. curl下载文件时自动创建目录

    有时候需要自动创建多级目录 按照如下格式即可 curl -o d:/lei/demo/test.jpg --create-dirs http://img.7160.com/uploads/allimg ...

  2. 代码测试:unsigned char*图像数据转换成OpenCV中Mat类型

    直接使用Mat的构造函数,把指针的位置赋给下面中的data就OK了: Mat(int rows, int cols, int type, void* data, size_t step=AUTO_ST ...

  3. 2019 ccpc 秦皇岛

    D 如果1/n是有限小数,不停乘以10,一定在有限次之后成为一个整数. 10的质因子只有2和5,只要保证分母的质因子只有2和5即可 #include <iostream> #include ...

  4. RequestContextHolder

    JShop简介:jshop是一套使用Java语言开发的B2C网店系统,致力于为个人和中小企业提供免费.好用的网店系统. 项目主页:http://git.oschina.net/dinguangx/js ...

  5. bigdata数据分析(二):关闭防火墙&安装telnet

    先检查CentOS7.0是否已经安装以下两个安装包:telnet-server.xinetd.命令如下: rpm -qa telnet-server rpm -qa xinetd 如果没有安装,则先安 ...

  6. 002-Django数据库及后台admin配置

    连接mysql数据库 数据库准备 如果连接本机数据库,mysql安装及配置可参考https://www.cnblogs.com/feizisy/p/11882521.html 如果连接阿里云RDS,需 ...

  7. 【BW系列】SAP BW实时抽取ECC数据的实现

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[BW系列]SAP BW实时抽取ECC数据的实现 ...

  8. Scratch少儿编程系列:(七)太阳系八大行星的运转

    一.程序说明 本程序用来模拟太阳系八大行星的运转过程. 二.程序流程图 为了更直观的描述上述过程,采用流程图的方式将猜数字的过程进行描述. 还在制作中... 三.制作过程 1. 场景和角色的选择 场景 ...

  9. Python中文件读写之 w+ 与 r+ 到底有啥区别?

    其实r 是只读,只能读不能写,这是很明确的,但是r+是可读写,变成r+后还没太明白到底加了什么,还是照样写不了,有没有这样的体验呢,如下代码,只读时 f = open("test.txt&q ...

  10. linux 扩展正则表达式 egrep

    使用命令为grep -E 及egrep [root@MongoDB ~]# cat mike.log I am mike! I like linux. I like play football, te ...