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:

  1. 3
  2. 1 2 3
  3. 2 3 4
  4. 9223372036854775807 -9223372036854775808 0

Sample Output:

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

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

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. Laravel提交POST请求报错

    提交POST请求出现如下错误: The page has expired due to inactivity Please refresh and try again 这是由于在Laravel框架中有 ...

  2. jquery 给input text元素赋值,js修改表单的值

    简单粗暴: (第一种) $('#checkUserName').attr("value",sessionUser.name); (第二种) $("#checkUserNa ...

  3. ES6中对字符串处理的优点

    目录 1.字符的Unicode表示法 2.字符串的遍历接口 3.直接输入 U+2028 和 U+2029(分行符 和 分段符) 4.JSON.stringify() 的改造 1.字符的Unicode表 ...

  4. js2flowchart

    https://github.com/Bogdan-Lyashenko/js-code-to-svg-flowchart js2flowchart - a visualization library ...

  5. Type.MakeGenericType 方法 (Type[]) 泛型反射

    替代由当前泛型类型定义的类型参数组成的类型数组的元素,并返回表示结果构造类型的 Type 对象. 命名空间:   System程序集:  mscorlib(mscorlib.dll 中) public ...

  6. pandas库简介和数据结构

    pandas简介 pandas是一个强大的Python数据分析的工具包.是基于Numpy来构件的. pandas提供快速.灵活和富有表现力的数据结构. 主要功能: 具备对其功能的数据结构DataFra ...

  7. Java多线程学习——join方法的使用

    join在线程里面意味着“插队”,哪个线程调用join代表哪个线程插队先执行——但是插谁的队是有讲究了,不是说你可以插到队头去做第一个吃螃蟹的人,而是插到在当前运行线程的前面,比如系统目前运行线程A, ...

  8. 那些搜过很多遍的python基础知识

    一. DataFrame 相关 1 索引的使用(.loc[] .iloc[]) .loc用行列标签来选择数据..iloc 根据行数与列数索引. import pandas as pd data = p ...

  9. finereport 带多参数查询

    1.sql语句 ${,""," and dt.货主地区='"+comboBox0+"'")} ${,""," ...

  10. java 内部编译异常的处理方法

    1.可能存在的问题. 在cmd 输入 java -version  和javac -version 检验java的环境是否正常,不正常就卸载重装. 搞定!