pat 甲级 1065. A+B and C (64bit) (20)
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 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
思路:要考虑溢出问题,若a,b都大于0,a+b溢出就一定会比大,同样a,b小于0且a+b溢出一定比c小。
AC代码:
#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<set>
#include<queue>
#include<map>
using namespace std;
#define INF 0x3f3f3f
#define N_MAX 1000+5
#define M_MAX 2001
typedef long long ll;
ll a, b, c;
int main() {
int t; cin >> t; int Case=;
while (t--) {
Case++;
cin >> a >> b >> c;
ll res = a + b;
if (a > && b > && res <= ) {//!!!溢出一定比c大
printf("Case #%d: true\n", Case); continue;
}
else if (a < && b < && res>=) {//!!溢出
printf("Case #%d: false\n", Case); continue;
}
else {
if (res > c) printf("Case #%d: true\n", Case);
else printf("Case #%d: false\n", Case);
}
}
return ;
}
pat 甲级 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 甲级 1065. A+B and C (64bit) (20) 【大数加法】
题目链接 https://www.patest.cn/contests/pat-a-practise/1065 思路 因为 a 和 b 都是 在 long long 范围内的 但是 a + b 可能会 ...
- PAT甲级——1065 A+B and C (64bit)
1065 A+B and C (64bit) Given three integers A, B and C in [−263,263], you are supposed to tell ...
- 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 ...
- 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)
1065. A+B and C (64bit) (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 HOU, Qiming G ...
- PAT甲级:1124 Raffle for Weibo Followers (20分)
PAT甲级:1124 Raffle for Weibo Followers (20分) 题干 John got a full mark on PAT. He was so happy that he ...
- PAT——甲级1065:A+B and C(64bit) 乙级1010一元多项式求导
甲级1065 1065 A+B and C (64bit) (20 point(s)) Given three integers A, B and C in [−263,263], you ...
- 【PAT甲级】1065 A+B and C (64bit) (20 分)(大数溢出)
题意: 输入三个整数A,B,C(long long范围内),输出是否A+B>C. trick: 测试点2包括溢出的数据,判断一下是否溢出即可. AAAAAccepted code: #defin ...
随机推荐
- wepy一些问题和解决方案
wepy一些问题和解决方案 小程序开发和传统的web开发有相识的地方,但是也有不同的地方,要区分. computed属性名和props属性名重复 如果那个组件的渲染值是重名的computed属性,每次 ...
- 洛谷P1049装箱问题
一句话刚刚的题会了,这题能不会么. #include<bits/stdc++.h> using namespace std; int main(){ int n,m; cin>> ...
- linux替换yum源及配置本地源
linux系统安装后自带的bash源由于在国外,安装软件包的时候会非常慢,最好替换一下yum源. 关于yum源的简单介绍 yum的主要功能是更方便地添加,删除和更新rpmba ...
- 整合mybatis和spring时 Error creating bean with name 'sqlSessionFactory' defined in class path resource
今天在整合mybatis和spring的时候出的错 报错如下 Exception in thread "main" org.springframework.beans.factor ...
- 源码级强力分析hadoop的RPC机制
分析对象: hadoop版本:hadoop 0.20.203.0 必备技术点: 1. 动态代理(参考 :http://weixiaolu.iteye.com/blog/1477774 )2. Java ...
- python并发编程相关概念总结
1.简述计算机操作系统中的“中断”的作用? 中断是指在计算机执行期间,系统内发生任何非寻常的或非预期的急需处理事件,使得CPU暂时中断当前正在执行的程序而转去执行相应的时间处理程序.待处理完毕后又返回 ...
- 【IPv6】ISATAP隧道技术详解
一.基本概念 ISATAP(Intra-SiteAutomatic Tunnel Addressing Protocol) ISATAP是一种非常容易部署和使用的IPv6过渡机制.在 ...
- RSA进阶之两个N的公约数
适用场景: 给你两个n,n1和n2. 两个数都很大,不好分解. 但是这数刚好有质数公因子(试试欧几里得辗转相除跑完之后,就是不断地相除就可以了,4000多位也是很快的),那不就相当于间接的分解出q或者 ...
- github 上传项目
注册账户以及创建仓库 要想使用github第一步当然是注册github账号了.之后就可以创建仓库了(免费用户只能建公共仓库),Create a New Repository,填好名称后Create,之 ...
- camelot工具进行pdf表格解析重建
camelot内置生成html文件的方法,但表格数据转化成pandas.dataframe的过程中,丢失了跨行跨列的结构信息,故生成html的表格无跨行跨列结构. 于是我在输出部分选择直接手写html ...