A1065. A+B and C (64bit)
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
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
int T;
long long a, b, c, test;
scanf("%d", &T);
for(int i = ; i < T; i++){
scanf("%lld%lld%lld", &a, &b, &c);
test = a + b;
if(a > && b > && test < ){
printf("Case #%d: true\n", i + );
}else if(a < && b < && test >= ){
printf("Case #%d: false\n", i + );
}else{
if(test > c)
printf("Case #%d: true\n", i + );
else
printf("Case #%d: false\n", i + );
}
}
return ;
}
总结:1、首先输入的范围在[-2^63, 2^63], 则只能用long long 8个byte存储。当a与b过大时,会产生溢出,需要考虑正数+正数=负数及负数+负数=正数的情况。
2、A + B的结果不能在条件语句中直接与C比较,必须先存储于long long变量中。
A1065. A+B and C (64bit)的更多相关文章
- 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 A1065 A+B and C (64bit) (20 分)
AC代码 #include <cstdio> int main() { #ifdef ONLINE_JUDGE #else freopen("1.txt", " ...
- PAT甲级——A1065 A+B and C (64bit)
Given three integers A, B and C in [−], you are supposed to tell whether A+B>C. Input Specificati ...
- PAT/简单模拟习题集(二)
B1018. 锤子剪刀布 (20) Discription: 大家应该都会玩"锤子剪刀布"的游戏:两人同时给出手势,胜负规则如图所示: 现给出两人的交锋记录,请统计双方的胜.平.负 ...
- PAT题目AC汇总(待补全)
题目AC汇总 甲级AC PAT A1001 A+B Format (20 分) PAT A1002 A+B for Polynomials(25) PAT A1005 Spell It Right ( ...
- 1065 A+B and C (64bit) (20 分)
1065 A+B and C (64bit) (20 分) Given three integers A, B and C in [−2^63,2^63], you are suppose ...
- 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 ...
随机推荐
- 读懂掌握 Python logging 模块源码 (附带一些 example)
搜了一下自己的 Blog 一直缺乏一篇 Python logging 模块的深度使用的文章.其实这个模块非常常用,也有非常多的滥用.所以看看源码来详细记录一篇属于 logging 模块的文章. 整个 ...
- 协程和异步io
一. 并发.并行.同步.异步.阻塞.非阻塞 1.并发:是指一个时间段中有几个程序都处于已启动运行到运行完毕之间,且这几个程序都是在同一个处理机(CPU)上运行,但任一个时刻点上只有一个程序在处理机上运 ...
- mvn clean compile package install deploy
(1) package 目的是打包,在pom中,如果是jar就会打包成jar,如果是war就会打包成war 在pom.xml中: <modelVersion></modelVersi ...
- delphi中退出是弹出让你确定的几种确定对话框怎么写?
procedure TForm2.btn1Click(Sender: TObject); begin if MessageBox(Handle, '你确定要退出系统吗?', '信息提示', MB_OK ...
- Dreamweaver怎样用Edge Web Fonts功能
https://jingyan.baidu.com/article/37bce2beb3af6f1002f3a2c9.html
- Essential Phone刷机教程
安装fastboot驱动(Essential-PH1-WindowsDrivers) 下载ADB刷机指令工具:platform-tools(ADB): 进入开发者选项,打开 USB 调试,OEM解锁选 ...
- 【python练习题】程序8
#题目:输出 9*9 乘法口诀表. for i in range(1,10): k = '' for j in range(1,i+1): k += '%s * %s = %s '%(i,j,i*j) ...
- json-lib和dom4j实现JSON转XML
package com.geostar.gfstack.operationcenter.test; import net.sf.json.JSONObject; import net.sf.json. ...
- mysql,mybatis模糊查询
<if test="deviceType != null and deviceType != ''">and device_type like CONCAT('%', ...
- JVM深入理解<一>
以下文章来自与: http://www.jianshu.com/p/fabad9250b1b 一.什么是JVM? JVM是Java Virtual Machine(Java虚拟机)的缩写,是通过在实际 ...