首页 技术 正文
技术 2022年11月16日
0 收藏 698 点赞 4,976 浏览 1032 个字

1065. A+B and C (64bit) (20)

时间限制100 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者HOU, Qiming

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 ;
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,489
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,904
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,737
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,490
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,128
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,290