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);
     }

     ;
 }

1065 A+B and C (64bit) (20 分)的更多相关文章

  1. PAT 甲级 1065 A+B and C (64bit) (20 分)(溢出判断)*

    1065 A+B and C (64bit) (20 分)   Given three integers A, B and C in [−], you are supposed to tell whe ...

  2. PAT Advanced 1065 A+B and C (64bit) (20 分)(关于g++和clang++修改后能使用)

    Given three integers A, B and C in [−], you are supposed to tell whether A+B>C. Input Specificati ...

  3. 【PAT甲级】1065 A+B and C (64bit) (20 分)(大数溢出)

    题意: 输入三个整数A,B,C(long long范围内),输出是否A+B>C. trick: 测试点2包括溢出的数据,判断一下是否溢出即可. AAAAAccepted code: #defin ...

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

    Given three integers A, B and C in [−], you are supposed to tell whether A+B>C. Input Specificati ...

  5. 1065 A+B and C (64bit) (20分) 测试点3 别用cin

    cin的话,处理不了这么大的数?? 要拐回scanf("%lld"): 啊啦搜

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

    1065. A+B and C (64bit) (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 HOU, Qiming G ...

  7. pat 甲级 1065. A+B and C (64bit) (20)

    1065. A+B and C (64bit) (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 HOU, Qiming G ...

  8. PAT 甲级 1065. A+B and C (64bit) (20) 【大数加法】

    题目链接 https://www.patest.cn/contests/pat-a-practise/1065 思路 因为 a 和 b 都是 在 long long 范围内的 但是 a + b 可能会 ...

  9. ZJU-PAT 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 S ...

  10. PAT A 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. Inpu ...

随机推荐

  1. 利用InstallShiled 10.5制作AE应用程序安装包

    [转]利用InstallShiled 10.5制作AE应用程序安装包 作者:3SNEWS 社区ESRI(ArcGIS)版版主:zhaoxiang_whuhttp://www.3snews.net/bb ...

  2. L208

    A hundred years ago it was assumed and scientifically “proved” by economists that the laws of societ ...

  3. PowerShell添加和部署WSP

    SharePoint PowerShell在SharePoint Product列表里边,然后以管理员权限启动. 1. 添加Solution 到 SharePoint Farm. Add-SPSolu ...

  4. TI AM335x Linux MUX hacking

    /********************************************************************************************* * TI ...

  5. zookeeper 官方文档——综述

      Zookeeper: 一个分布式应用的分布式协调服务   zookeeper 是一个分布式的,开源的协调服务框架,服务于分布式应用程序.   它暴露了一系列基础操作服务,因此,分布式应用能够基于这 ...

  6. HDU 1024:Max Sum Plus Plus(DP,最大m子段和)

    Max Sum Plus Plus Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  7. bool dfs 解决单一解问题的优越性

    dfs的返回值类型可以是int 或者 void  .bool 由void 与 int 作为返回值类型的dfs在得到解之后不能立即返回,即使你加上语句if(key)return;也要在得到解之后一点点返 ...

  8. statik golang 静态资源嵌入二进制文件工具使用(docker 构建)

      将静态资源打包进二进制文件有好多方便的地方 方便客户演示 代码简单加密 运行方便 statik 就是一款在golang 中用的比较多,nodejs 有一款pkg (oclif 就推荐使用此工具) ...

  9. IEPNGFix 解决IE6支持PNG透明问题

    IE6本身是支持索引色透明度(PNG8)格式,但不支持真彩色透明度(PNG24)格式. 使用IE PNG Fix 2.0可以完美解决IE6支持PNG透明问题,而且支持背景定位和重复属性. IE PNG ...

  10. MSG命令使用详解

    最近在编写FTP上传数据的批处理时,需要用到局域网内传输数据来提示错误,突然想起忘了N久没用的命令(net send),  结果在win7 下cmd运行net send /? 运行失败.经过百度大神的 ...