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
//long long 有效位为[-2^63,2^63,),如果a,b取到临界点,会出现溢出。
// A+B最大为 2^64-2(左开右闭),(2^64-2)%2^63=-2,long long的正溢出的范围为[-2^63,-2]
// 所以A>0,B>0,A+B<0时,为正溢出,结果为true。
//相同long long负溢出范围为[0,2^63],当A<0,B<0,A+B>=0时结果为负
#include<cstdio>
int main(){
int k,Tcase = ; //变量不能用case
scanf("%d",&k);
for(int i = ; i < k; i++){
long long a,b,c;
scanf("%lld%lld%lld",&a,&b,&c);
long long res;
res = a + b;
bool flag;
if(a < && b < && res >= ) flag = false; // 负溢出时等号可以取到
else if(a > && b > && res < ) flag = true; //正溢出为true,负溢出为false
else if(res > c) flag = true;
else flag = false;
if(flag == true) printf("Case #%d: true\n",Tcase++);
else printf("Case #%d: false\n",Tcase++);
}
return ;
}

最新文章

  1. 传统瀑布式&amp;敏捷开发
  2. jquery.cookie.js &amp;&amp; java后台代码 操作cookie实现记住当前用户输入信息代码
  3. 找回MSI安装包Win7/Win8管理员身份功能
  4. BZOJ 3363: [Usaco2004 Feb]Cow Marathon 奶牛马拉松
  5. 卸载Oracle步骤
  6. C#中跨线程访问控件问题解决方案
  7. 【jmeter】关联-正则表达和xpath
  8. Leaflet实现动态线路
  9. Taskctl安装及配置Kettle插件
  10. PHP:自己写的mysql操作类
  11. 通用redis命令
  12. UESTC 1034 AC Milan VS Juventus 分情况讨论
  13. 安全之路 —— C/C++实现利用添加注册表项实现文件自启动
  14. Android:Unable to find explicit activity class
  15. 如何将在线电子书保存为pdf格式
  16. spark的shuffle和原理分析
  17. 分布式搜索elasticsearch几个概念解析
  18. Appuim学习路-Appuim介绍
  19. 在centos7.1上安装systemd
  20. 安装和使用mongodb

热门文章

  1. [Python Study Notes]pynput实现对键盘控制与监控
  2. Class类动态加载类的用法
  3. 数据库开源框架ormlite
  4. 【总结整理】地理信息系统GIS的基础坐标知识
  5. 利用powerdesigner创建表模型后导出sql语句方法,以及报错 Generation aborted due to errors detected during the verification of the model.的解决办法
  6. webfrom 母版页
  7. 10、R常用命令
  8. Luogu 3627 [APIO2009]抢掠计划
  9. c++线程调用python
  10. sina 接口 根据ip获取各个国家和地区