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. 高版本的jdk编译过的项目移到低版本的JDK的eclipse中出错的问题

    由于2台电脑安装的jdk版本不一样,导致从一台电脑移动项目到另一台电脑上时,运行出现了错误,错误信息如下: 主要是原先项目运行的JDK版本为1.8, 而要移过去的电脑的jdk是1.7的,首先已经把bu ...

  2. <?xml version="1.0" encoding="UTF-8" standalone="no"?>

    XML standalone 定义了外部定义的 DTD 文件的存在性. standalone element 有效值是 yes 和 no. 如下是一个例子: <?xml version=&quo ...

  3. ASI 实现注册方法的小例子(get和post方式)

    服务端文档: 注册 /my/register.php 输入参数: 参数说明: username 用户名 password 密码 email 邮箱 成功返回值:{"code": &q ...

  4. 人工智能是如何改变IT运维和DevOps的?

    要解决IT运维和DevOps团队面对的挑战,就是能够在大量的日志数据流中识别潜在的小的有害问题,这正是认知洞察力所做的事情. 接下来的几年里,DevOps(开发软件工程.技术运营和质量保障三者的交集) ...

  5. Pandas 命令整理

    在网上看到一个整理的很好的pandas命令合集,转一份供自己查找与参考

  6. magento优化

    magento -- SEO优化继续往前走一步 magento的SEO做的实在太好了,让其它的电子商务平台与之相比实在是不是一个重级的,这也许就是magento成功的原因.尽管现在结合apache,实 ...

  7. git中的needs merge问题

    这个问题是在先“储藏”起来了,后面再调用出来出现的错误. 解决的方法就是通过git add    ,git commit -m  提交上去就可以了.

  8. [LeetCode&Python] Problem 682. Baseball Game

    You're now a baseball game point recorder. Given a list of strings, each string can be one of the 4 ...

  9. [LeetCode&Python] Problem 806. Number of Lines To Write String

    We are to write the letters of a given string S, from left to right into lines. Each line has maximu ...

  10. HPU 1476: 括号括号

    1476: 括号括号 时间限制: 3 Sec 内存限制: 128 MB 提交: 305 解决: 61 统计 题目描述 小明今年上大学,在大学里发现有很多同学都女朋友,两人整天都在一起腻歪,小明看到后感 ...