PAT1065: A+B and C (64bit)
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 思路
注意溢出的情况就行,其他情况正常比较,溢出分两种情况:
1. A > 0,B > 0, Sum = A + B 正溢出,溢出后的值Sum <= 0;
2. A < 0,B < 0, Sum = A + B 负溢出,溢出后的值Sum >= 0; 代码
#include<iostream>
#include<vector>
using namespace std;
int main()
{
int T;
while(cin >> T)
{
long long a,b,c;
for(int i = ; i <= T; i++)
{
cin >> a >> b >> c;
long long sum = a + b; if(a < && b < && sum >= ) //最小负数相加溢出
cout << "Case #" << i <<": false" << endl;
else if(a > && b > && sum <= ) //最大正数相加溢出
cout << "Case #" << i <<": true" << endl;
else if(sum > c)
cout << "Case #" << i <<": true" << endl;
else
cout << "Case #" << i <<": false" << endl;
}
}
return ;
}
PAT1065: A+B and C (64bit)的更多相关文章
- Can't load IA 32-bit .dll on a AMD 64-bit platform错误的解决
64位的系统,64位的myeclipse,64位的jdk,64位的tomcat,结果报错:Can't load IA 64-bit .dll on a AMD 32-bit platform,简直无语 ...
- Ubuntu 14.04 64bit 安装tensorflow(GPU版本)
本博客主要用于在Ubuntu14.04 64bit 操作系统上搭建google开源的深度学习框架tensorflow. 0.安装CUDA和cuDNN 如果要安装GPU版本的tensorflow,就必须 ...
- Caffe学习笔记2--Ubuntu 14.04 64bit 安装Caffe(GPU版本)
0.检查配置 1. VMWare上运行的Ubuntu,并不能支持真实的GPU(除了特定版本的VMWare和特定的GPU,要求条件严格,所以我在VMWare上搭建好了Caffe环境后,又重新在Windo ...
- Window7下安装Ubuntu 14.04 64bit
本文章主要讲解如何在Windows7操作系统中硬盘安装Ubuntu 14.04 64bit: 1.准备文件 1.ubuntu-14.04.4-desktop-amd64.iso 2.EasyBCD.e ...
- Caffe学习笔记1--Ubuntu 14.04 64bit caffe安装
本篇博客主要用于记录Ubuntu 14.04 64bit操作系统搭建caffe环境,目前针对的的是CPU版本: 1.安装依赖库 sudo apt-get install libprotobuf-dev ...
- 如何完全卸载OneDrive (Windows 10 64bit)
原文参考 http://lifehacker.com/how-to-completely-uninstall-onedrive-in-windows-10-1725363532 To complete ...
- RHEL6 64位系统安装ORACLE 10g 64bit 数据库
记得去年4月份的时候,为公司部署测试环境和UAT环境时,在红帽RHEL6 64位系统安装ORACLE 10g 64位数据库时遇到了许多小问题,当时匆匆忙忙也没记录一下这些问题,前几天在虚拟机安装ORA ...
- Win7 下安装VirtualBox 没有Ubuntu 64bit 选项问题
参考: win7安装virtualbox遇到的问题 基于VirtualBox虚拟机安装Ubuntu图文教程 问题 在安装VirtualBox之后,选择虚拟机进行安装的时候发现没有Ubuntu 64bi ...
- 关于Linux x64 Oracle JDK7u60 64-bit HotSpot VM 线程栈默认大小问题的整理
JVM线程的栈默认大小,oracle官网有简单描述: In Java SE 6, the default on Sparc is 512k in the 32-bit VM, and 1024k in ...
随机推荐
- Oracle Service Bus 11g 的三种方案
使用<Oracle Service Bus 11g Development Cookbook>中的方案迅速推出一批全新的面向服务和消息的解决方案 2012 年 3 月 (单击图像了解更 ...
- 标准会话管理器——StandardManager
用于保存状态的会话对象已经有了,现在就需要一个管理器来管理所有会话,例如会话id生成.根据会话id找出对应的会话.对于过期的会话进行销毁等等操作.用一句话描述标准会话管理器:提供一个专门管理某个web ...
- 【一天一道LeetCode】 #3 Longest Substring Without Repeating Characters
一天一道LeetCode (一)题目 Given a string, find the length of the longest substring without repeating charac ...
- ITU-T Technical Paper: IP服务性能模型
本文翻译自ITU-T的Technical Paper:<How to increase QoS/QoE of IP-based platform(s) to regionally agreed ...
- LeetCode之“数学”:Happy Number
题目链接 题目要求: Write an algorithm to determine if a number is "happy". A happy number is a num ...
- XMPP系列(二)----用户注册和用户登录功能
1.创建一个新工程 2.导入XMPP框架 最新的XMPP框架下载地址:https://github.com/robbiehanson/XMPPFramework 将XMPP的几个文件夹拖进工程中,需要 ...
- Http的定义及其基本概念介绍
HTTP的特性 HTTP构建于TCP/IP协议之上,默认端口号是80 HTTP是无连接无状态的 HTTP报文 请求报文 HTTP定义了与服务器交互的不同方法,最基本的方法有4种,分别是GET,POST ...
- gcc或clang中消除特定警告的方法
一般在编译代码时会有相当多的警告信息,尤其当我们使用了-Wall选项的时候.-Wall绝不是像其字面意思一样打开所有警告.不过它打开的警告也相当多了.对于一些我们已知"无害"但仍然 ...
- SpringBoot2.0之一 新建项目helloWorld
SpringBoot 以简单快速很快获得了广大开发者的青睐,本套SpringBoot系列以最新的SpringBoot 2.0为基础,同时会提及不同版本下SpringBoot的修改和变化,如有理解不当的 ...
- Linux的pwd命令详解
在Linux层次结构中,用户可以在被授权的任意目录下利用mkdir命令创建新目录,也可以利用cd命令从一个目录转换到另一个目录.然而,没有提示符来告知用户目前处于哪一个目录中.想要知道当前所处的目录, ...