1065. A+B and C (64bit) (20)
来源:互联网 发布:知乎 苏德战争 编辑:程序博客网 时间:2024/06/06 00:23
一开始用大数运算···就像某网友说的:已哭晕在厕所···
根据题中要求:
①考虑到溢出
A>0&&B>0 而A+B<=0 或 A<0&&B<0 而A+B>=0 这两种情况即为 溢出 容易判断 前者必定大于未溢出的C而后者必定小于未溢出的C
②未溢出的 直接用用long long 进行判断
#include<iostream>#include<cstring>#include<map>#include<string>#include<cmath>#include<algorithm>using namespace std;int main(){ int T; long long A, B, C, Sum; cin>>T; for(int i=1; i<=T; i++) { bool ans; cin>>A>>B>>C; Sum=A+B; if(A>0&&B>0&&Sum<=0) ans=true; else if(A<0&&B<0&&Sum>=0) ans=false; else { ans=(Sum>C ? true:false); } cout<<"Case #"<<i<<": "<<(ans ? "true" : "false")<<endl; } return 0;}
0 0
- PAT A 1065. A+B and C (64bit) (20)
- PAT-A 1065. A+B and C (64bit) (20)
- PAT-A-1065. A+B and C (64bit) (20)
- 1065. A+B and C (64bit)
- 1065. A+B and C (64bit)
- 1065. A+B and C (64bit)
- 1065.A+B and C (64bit)
- 1065. A+B and C (64bit)
- 1065. A+B and C (64bit)
- 1065. A+B and C (64bit)
- 1065. A+B and C (64bit)
- 1065. A+B and C (64bit)
- 1065. A+B and C (64bit)
- A+B and C (64bit) (20)
- 1065. A+B and C (64bit) (20)
- 【PAT】1065. A+B and C (64bit) (20)
- 1065. A+B and C (64bit) (20)
- 1065. A+B and C (64bit) (20)
- 自学Qt之中文显示(QMessageBox、QLineEdit右键菜单等)
- HTML5 webSQL动态查询应用截图
- 解析数据封装对象的时候出现重名问题
- Go语言并发编程(二)
- [leetcode] 14.Longest Common Prefix
- 1065. A+B and C (64bit) (20)
- 重载赋值运算符返回reference to *this(Effective C++_10)
- Hadoop入门进阶课程5--MapReduce原理及操作
- Android4.0 Launcher拖拽原理分析(一)
- sqlite字段类型
- Android Studio错误1
- php获取当前页地址
- thinkphp前台格式化输出日期
- JSON用法简介