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

Given three integers A, B and C in [−2^​63​​,2​^63​​], 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

分析:这个题有坑点,涉及到计算机组成原理的知识,数字的范围是[−2^​63​​,2​^63​​], 而long long 的范围是[-2^63,2^63),两个数相加会溢出,符号位会取反。
 /**
 * Copyright(c)
 * All rights reserved.
 * Author : Mered1th
 * Date : 2019-02-23-19.49.08
 * Description : A1065
 */
 #include<cstdio>
 #include<cstring>
 #include<iostream>
 #include<cmath>
 #include<algorithm>
 #include<string>
 #include<unordered_set>
 #include<map>
 #include<vector>
 #include<set>
 using namespace std;

 int main(){
 #ifdef ONLINE_JUDGE
 #else
     freopen("1.txt", "r", stdin);
 #endif
     ;
     scanf("%d",&n);
     ;i<=n;i++){
         long long a,b,c;
         scanf("%lld%lld%lld",&a,&b,&c);
         bool flag;
         long long res=a+b;
         &&b>&&res<) flag=true;
         &&b<&&res>=) flag=false;
         else if(res>c) flag=true;
         else flag=false;
         if(flag==true) printf("Case #%d: true\n",i);
         else printf("Case #%d: false\n",i);
     }

     ;
 }

最新文章

  1. SSH实战 &#183; 唯唯乐购项目(中)
  2. 移动混合开发之android文件管理demo
  3. PAT (Advanced Level) Practise:1027. Colors in Mars
  4. .net网站发布到局域网流程
  5. Hadoop伪分布式搭建CentOS
  6. Lepus经历收获杂谈(一)——confirm features的小工具
  7. hihocoder 1237 Farthest Point
  8. Werkzeug教程
  9. thrift之TTransport类体系原理及源码详细解析1-类结构和抽象基类
  10. 定时改变App主题的方案
  11. jquery 实现 隐藏交替同时记住以前隐藏的样式
  12. 第一章Python起步
  13. BZOJ_3675_[Apio2014]序列分割_斜率优化
  14. 使用pymongo连接mongodb时报错:pymongo.errors.OperationFailure: not authorized
  15. 11-border(边框)
  16. [ 9.12 ]CF每日一题系列—— 960B暴力数组
  17. 混沌分形之逻辑斯蒂(Logistic)映射系统
  18. zabbix_agentd在windows上安装
  19. 51nod1563
  20. 【bzoj3930】 CQOI2015—选数

热门文章

  1. 26个你不知道的Python技巧
  2. Maven学习- 使用Maven构建Web项目
  3. HDU 2853 &amp;&amp; HDU 3315
  4. [LeetCode&amp;Python] Problem 804. Unique Morse Code Words
  5. explain结果字段说明
  6. python3反射
  7. UTF-8编码占几个字节?
  8. 租酥雨的NOIP2018赛前日记
  9. ppt正文排版
  10. 【vue】Mac上安装Node和NPM