1065 A+B and C (64bit) (20分)(水)
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
题目分析:利用long long 存储数据 但是要注意对于num的判断 因为long long 最大存储范围是从负2的63次 到 正2的63次减一
如果这个和大于或小于这个范围 就要先判断再输出
对于这道题来说
数的范围是 $[-2^63,2^63]$ 而longlong的范围是$[-2^63,2^63-1]$
若两个数的和过大到区间$[2^63,2^64-2] 那么会溢出改变到区间 [-2^63,-2](对于非浮点数来说上界加一会变为加一后的值取负 故(2^63-1+1)会变为-2^63 -2是根据公式 (2^64-2)%2^64=-2求得$
同理 若过小到区间$[-2^64,-2^63-1] 会溢出改变到区间[0,2^63-1]$
#define _CRT_SECURE_NO_WARNINGS
#include <climits>
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
string A, B, C; int main()
{
int N;
cin >> N;
for (int i = ; i <= N; i++)
{
long long A, B, C;
cin >> A >> B >> C;
long long num = A + B;
if (A > && B > && num < )
printf("Case #%d: true\n", i);
else if (A < && B < && num >= )
printf("Case #%d: false\n", i);
else if(num > C)
printf("Case #%d: true\n", i);
else
printf("Case #%d: false\n", i);
}
}
1065 A+B and C (64bit) (20分)(水)的更多相关文章
- 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 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 Specificati ...
- 【PAT甲级】1065 A+B and C (64bit) (20 分)(大数溢出)
题意: 输入三个整数A,B,C(long long范围内),输出是否A+B>C. trick: 测试点2包括溢出的数据,判断一下是否溢出即可. AAAAAccepted code: #defin ...
- 1065 A+B and C (64bit) (20分) 测试点3 别用cin
cin的话,处理不了这么大的数?? 要拐回scanf("%lld"): 啊啦搜
- 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)
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 可能会 ...
- ZJU-PAT 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. Input S ...
- 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 ...
随机推荐
- cocos2d-x android 入门
前一段时间使用传统方式做了一个CS软件,发现 UI 显示的比较慢,突发奇起,开始研究起来 GPU 加速,最后开始学习 cocos2dx. 开发环境以最新的 Cocos2d-x 3.17.1 Andro ...
- Linux环境下安装MySQL 5.7.28
先进入MySQL官网: www.mysql.com 去下载安装包 进入DOWNLOADS选项,点击MySQL Community (GPL) Downloads. 点击进入MySQL Communit ...
- Python操作系统
一 为什么要有操作系统 (两本书:现代操作系统.操作系统原理,学好python以后再去研究吧~~) 现代的计算机系统主要是由一个或者多个处理器,主存,硬盘,键盘,鼠标,显示器,打印机,网络接口及其他输 ...
- sessionStorage localStorage 和 cookie 之间的区别转
sessionStorage 和 localStorage 是HTML5 Web Storage API 提供的,可以方便的在web请求之间保存数据.有了本地数据,就可以避免数据在浏览器和服务器间不必 ...
- 0919-The Standard of Code Review
The primary purpose of code review is to make sure that the overall code health of Google’s code bas ...
- 基于Ubuntu的ORB-SLAM2项目环境搭建过程
目录 关于ORB-SLAM2 环境搭建 已有环境 创建环境 新建项目目录 安装Pangolin 安装OpenCV 3.2 安装Eigen DBoW2 and g2o (Included in Thir ...
- Mol Cell Proteomics. | 用于鉴定新型融合转录本及其在癌细胞中的潜在翻译产物的多功能蛋白质组基因组学工具FusionPro
期刊:Molecular & Cellular Proteomics 发表时间:June 17, 2019 DOI:10.1074/mcp.RA119.001456 分享人:任哲 内容与观点: ...
- MybatisPlus SQL 打印控制台
#applicaton.yml 配置 mybatis-plus: configuration: # 是否将sql打印到控制面板(该配置会将sql语句和查询的结果都打印到控制台) log-impl: o ...
- jQuery的简单用法(jQuery的简介,选择器,属性和css,文档处理)
一.jQuery简介 1.1. JS库 JavaScript 库封装了很多预定义的对象和实用函数.能帮助使用者建立有高难度交互客户端页面, 并且兼容各大浏览器. 1.2. 当前流行的 JavaSc ...
- 论文速递 | 实例分割算法BlendMask,实时又state-of-the-art
BlendMask通过更合理的blender模块融合top-level和low-level的语义信息来提取更准确的实例分割特征,该模型效果达到state-of-the-art,但结构十分精简,推理速度 ...