PAT 65. A+B and C (64bit) (20)
题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1065
思路分析:
1)对a+b造成的long long 类型的数据溢出进行特殊处理:
a>0 && b>0 && a+b<=0 :则a+b必大于c
a<0 && b<0 && a+b>=0 :则a+b必小于c
#include <stdio.h>
#include <stdlib.h> int main(int argc,char *argv[]){
long long a,b,res; int n;
scanf("%d",&n);
bool flag;
for(int i=;i<=n;i++){
scanf("%lld %lld %lld",&a,&b,&res);
long long tmp=a+b; if(a> && b> && tmp<=)flag=true;
else if(a< && b< && tmp>=) flag=false;
else flag=a+b>tmp; printf("Case #%d:",i);
if(flag) puts("true");
else puts("false");
} system("pause");
return ;
}
PAT 65. A+B and C (64bit) (20)的更多相关文章
- 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 A1065 A+B and C (64bit) (20 分)
AC代码 #include <cstdio> int main() { #ifdef ONLINE_JUDGE #else freopen("1.txt", " ...
- 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 分) Given three integers A, B and C in [−], you are supposed to tell whe ...
- PAT 1065 A+B and C (64bit)
1065 A+B and C (64bit) (20 分) Given three integers A, B and C in [−], you are supposed to tell whe ...
- A1065 A+B and C (64bit) (20)(20 分)
A1065 A+B and C (64bit) (20)(20 分) Given three integers A, B and C in [-2^63^, 2^63^], you are suppo ...
- PAT (Advanced Level) Practice 1046 Shortest Distance (20 分) 凌宸1642
PAT (Advanced Level) Practice 1046 Shortest Distance (20 分) 凌宸1642 题目描述: The task is really simple: ...
- PAT (Advanced Level) Practice 1042 Shuffling Machine (20 分) 凌宸1642
PAT (Advanced Level) Practice 1042 Shuffling Machine (20 分) 凌宸1642 题目描述: Shuffling is a procedure us ...
- PAT (Advanced Level) Practice 1041 Be Unique (20 分) 凌宸1642
PAT (Advanced Level) Practice 1041 Be Unique (20 分) 凌宸1642 题目描述: Being unique is so important to peo ...
随机推荐
- MySQL学习笔记(3) - 查询服务器版本,当前时间,当前用户
SELECT VERSION(); --显示当前服务器版本 SELECT NOW(); --显示当前日期时间 SELECT USER(); --显示当前用户 MySQL中语句规范: 1.关键字和函数名 ...
- 总结JavaScript输出内容(document.write)
document.write() 可用于直接向 HTML 输出流写内容.简单的说就是直接在网页中输出内容. 第一种:输出内容用“”括起,直接输出""号内的内容.<script ...
- 小巧实用的数字加减插件(jquery插件)
2015-12-04 近期项目需要,我将插件更新了,增加了两个参数,一个参数控制文本框是否支持输入,另一个参数则是新增了一个回调函数,返回文本框内的值.另外对代码局部重构了,优化了一下封装,需要的朋友 ...
- 左右推拽显示对比图 - jQyery封装 - 附源文件
闲来无事,做了一个模块效果 左右拖拽显示对比图,是用jq封装的 利用鼠标距离左侧(0,0)坐标的横坐标位移来控制绝对定位的left值 再配合背景图fixed属性,来制作视觉差效果 代码如下 <! ...
- [Mugeda HTML5技术教程之3] Hello World: 第一个Mugeda动画
今天我们开始我们的第一个Mugeda动画作品,并通过它来看看制作Mugeda动画的一些通用流程.在开始制作之前,请确保你已经拥有一个Mugeda网站的账号.如果还没有,你可以登录 www.mugeda ...
- shopnc B2B2C商城 Nginx下开启伪静态
B2B2C商城 Nginx下开启伪静态,伪静态开启后,对系统的SEO极为有利,可以最大限度让商城页面被搜索引擎抓取,但在实际安装中,很多客户在这块都会遇到各种各样的问题. 1. 编辑商城配置文件(da ...
- ie7 不兼容overflow:hidden;
用overflow:hidden; 隐藏不需要显示的数据,在IE6\IE8都显示正常,但是在ie7中就是不起作用,万恶的IE7啊.后来加了一句position:relative; 好了... stat ...
- String 和 string 的区别
string是c#中的类,String是.net Framework的类(在c# IDE中不会显示蓝色)c# string映射为.net Framework的String如果用string,编译器会把 ...
- cygwin编译SDL1.2
1.下载了一个SDL-1.2.14.tar.gz 2.下载一个cygwin64对SDL-1.2.14.tar.gz解压 tar -zxvf SDL-1.2.14.tar.gz 在网上找的大概是需要需要 ...
- MVC 中引入Jquery文件的几种方法
方法1: <script src="@Url.Content("~/Scripts/jquery-1.9.1.js")" type="text/ ...