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. 子域名爆破&C段查询&调用Bing查询同IP网站

    在线子域名爆破 <?php function domainfuzz($domain) { $ip = gethostbyname($domain); preg_match("/\d+\ ...

  2. UIViewController简述

    一.View Controller Classes 二.自定义UIVIewController 1.创建 a)nib文件 [cpp] view plaincopyprint?   - (BOOL)ap ...

  3. myecilpse +TOMCAT+web:jsp向mysql添加数据,查询在jsp页面显示

    <%@ page language="java" import="java.util.*" import="com.mysql.jdbc.Dri ...

  4. SQL之join

    QL join 用于根据两个或多个表中的列之间的关系,从这些表中查询数据. 有时为了得到完整的结果,我们需要从两个或更多的表中获取结果.我们就需要执行 join. 数据库中的表可通过键将彼此联系起来. ...

  5. SWIFT推送之本地推送(UILocalNotification)之二带按钮的消息

    上一篇讲到的本地推送是普通的消息推送,本篇要讲一下带按钮动作的推送消息,先上个图瞅瞅: 继上一篇的内容进行小小的改动: 在didFinishLaunchingWithOptions方法内进行以下修改 ...

  6. LG3684 [CERC2016]机棚障碍 Hangar Hurdles

    题意 题目描述 你正在评估一些关于一个巨型飞机仓库的建设计划.飞机仓库的地面可以表示为n行n列的网格图,其中每个格子要么是空的,要么有障碍物.行从上到下依次被编号为1到n,列从左到右依次被编号为1到n ...

  7. LG3812 【模板】线性基

    题意 给定n个整数(数字可能重复),求在这些数中选取任意个,使得他们的异或和最大. \(1≤n≤50,0≤S_i≤2^{50}\) 分析 模板题. 推荐一篇好博客 现在我来证明一下线性基的性质. 性质 ...

  8. 使用 C# 编写简易 ASP.NET Web 服务器 ---- 模拟IIS的处理过程

    如果你想获得更好的阅读体验,可以前往我在 github 上的博客进行阅读,http://lcomplete.github.io/blog/2013/07/16/use-csharp-write-asp ...

  9. bootstrap modal模态框的运用

    http://www.ziqiangxuetang.com/bootstrap/bootstrap-modal-plugin.html 方法 下面是一些可与 modal() 一起使用的有用的方法. 方 ...

  10. SQL 存储过程入门(五)

    好久没来博客园留下点东西,忙到找工作,最近把工作落实了. 最近公司的业务都是存储过程开发,发现去维护起来相当困难. 由于是维护项目,产品很久前都发布了,然而有一些修改,让我们去修改现在的逻辑,去看懂人 ...