1065 A+B and C (64bit) (20 分)
Given three integers A, B and C in [−2^63,2^63], 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 (≤10). 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^63,2^63], 而long long 的范围是[-2^63,2^63),两个数相加会溢出,符号位会取反。
/**
* Copyright(c)
* All rights reserved.
* Author : Mered1th
* Date : 2019-02-23-19.49.08
* Description : A1065
*/
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<unordered_set>
#include<map>
#include<vector>
#include<set>
using namespace std;
int main(){
#ifdef ONLINE_JUDGE
#else
freopen("1.txt", "r", stdin);
#endif
;
scanf("%d",&n);
;i<=n;i++){
long long a,b,c;
scanf("%lld%lld%lld",&a,&b,&c);
bool flag;
long long res=a+b;
&&b>&&res<) flag=true;
&&b<&&res>=) flag=false;
else if(res>c) flag=true;
else flag=false;
if(flag==true) 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分)(水)
Given three integers A, B and C in [−], you are supposed to tell whether A+B>C. Input Specificati ...
- 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 ...
随机推荐
- MyEclipse WebSphere开发教程:WebSphere 8安装指南(二)
[周年庆]MyEclipse个人授权 折扣低至冰点!立即开抢>> [MyEclipse最新版下载] IBM为使用WebSphere测试应用程序的开发人员提供了免费的WebSphere Ap ...
- 如何快速切换目录cd-linux
前言 cd命令是linux系统中的基本命令行,表示改变工作目录.本文主要介绍几个常用的cd命令. 系统环境 OS:ubuntu16.04. 操作过程 cd www 表示切换到www目录: cd .. ...
- 很全面的WinRAR实用技巧系列 - imsoft.cnblogs
WinRAR也可以管理我的桌面时间长了,桌面上堆的东西实在太多,平时该如何管理呢?安装了WinRAR的朋友可以请它来帮忙,用它管理清除无用的桌面文件或图标. 以XP系统为例,系统所在目录是“c:\wi ...
- Fire! 又是图 bfs
Joe works in a maze. Unfortunately, portions of the maze havecaught on re, and the owner of the ma ...
- excel导出: mac safari对application/x-msdownload的支持不佳
https://blog.csdn.net/lizeyang/article/details/8982155?locationNum=3&fps=1 http://tool.oschina.n ...
- leetcode:Count and Say【Python版】
一次AC 字符串就是:count+char class Solution: # @return a string def countAndSay(self, n): str = " for ...
- 转 微软发布TX(LINQ To Logs And Traces)
作者 Roopesh Shenoy ,译者 马德奎 发布于 一月 09, 2014 | 微软开源技术公司于近日发布了Tx,这是一个开源项目,可以使用日志/跟踪文件辅助调试,以及创建实时监控和告警系统. ...
- MySQL Group Replication
group replication是一种全新的高可用,高扩张的MySQL集群服务.高一致性,基于原生复制及paxos协议的组复制技术,以插件方式提供一致数据安全保证:高容错性,大多数服务正常就可继续工 ...
- TNS-12535 TNS-00505的处理方法
原文地址:TNS-12535 TNS-00505的处理方法 作者:wzq609 硬件说明: 操作系统版本:ORACLE LINUX 6.3 64位 数据库版本:11.2.0.3 64位 问题说明 ...
- JVM内存模型(二)
JVM为什么要区分为栈和堆? 栈代表的操作逻辑存储,堆代表的是数据逻辑存储,这样来划分更加清晰: JVM的内存在宏观上面来讲分为私有内存和共享内存:所谓共享内存(堆)寓意就是各个私有的栈(每个线程私有 ...