PAT Advanced 1065 A+B and C (64bit) (20 分)(关于g++和clang++修改后能使用)
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++修改后能使用)的更多相关文章
- 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 ...
- 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 ...
- PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642
PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642 题目描述: A number that will ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- PAT 甲级 1065. A+B and C (64bit) (20) 【大数加法】
题目链接 https://www.patest.cn/contests/pat-a-practise/1065 思路 因为 a 和 b 都是 在 long long 范围内的 但是 a + b 可能会 ...
- 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 ...
随机推荐
- Laravel提交POST请求报错
提交POST请求出现如下错误: The page has expired due to inactivity Please refresh and try again 这是由于在Laravel框架中有 ...
- jquery 给input text元素赋值,js修改表单的值
简单粗暴: (第一种) $('#checkUserName').attr("value",sessionUser.name); (第二种) $("#checkUserNa ...
- ES6中对字符串处理的优点
目录 1.字符的Unicode表示法 2.字符串的遍历接口 3.直接输入 U+2028 和 U+2029(分行符 和 分段符) 4.JSON.stringify() 的改造 1.字符的Unicode表 ...
- js2flowchart
https://github.com/Bogdan-Lyashenko/js-code-to-svg-flowchart js2flowchart - a visualization library ...
- Type.MakeGenericType 方法 (Type[]) 泛型反射
替代由当前泛型类型定义的类型参数组成的类型数组的元素,并返回表示结果构造类型的 Type 对象. 命名空间: System程序集: mscorlib(mscorlib.dll 中) public ...
- pandas库简介和数据结构
pandas简介 pandas是一个强大的Python数据分析的工具包.是基于Numpy来构件的. pandas提供快速.灵活和富有表现力的数据结构. 主要功能: 具备对其功能的数据结构DataFra ...
- Java多线程学习——join方法的使用
join在线程里面意味着“插队”,哪个线程调用join代表哪个线程插队先执行——但是插谁的队是有讲究了,不是说你可以插到队头去做第一个吃螃蟹的人,而是插到在当前运行线程的前面,比如系统目前运行线程A, ...
- 那些搜过很多遍的python基础知识
一. DataFrame 相关 1 索引的使用(.loc[] .iloc[]) .loc用行列标签来选择数据..iloc 根据行数与列数索引. import pandas as pd data = p ...
- finereport 带多参数查询
1.sql语句 ${,""," and dt.货主地区='"+comboBox0+"'")} ${,""," ...
- java 内部编译异常的处理方法
1.可能存在的问题. 在cmd 输入 java -version 和javac -version 检验java的环境是否正常,不正常就卸载重装. 搞定!