Given three integers A, B and C in [−], 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 (≤). 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 存储数据 但是要注意对于num的判断 因为long long 最大存储范围是从负2的63次 到 正2的63次减一
如果这个和大于或小于这个范围 就要先判断再输出
对于这道题来说
数的范围是 $[-2^63,2^63]$ 而longlong的范围是$[-2^63,2^63-1]$
若两个数的和过大到区间$[2^63,2^64-2] 那么会溢出改变到区间 [-2^63,-2](对于非浮点数来说上界加一会变为加一后的值取负 故(2^63-1+1)会变为-2^63 -2是根据公式 (2^64-2)%2^64=-2求得$
同理 若过小到区间$[-2^64,-2^63-1] 会溢出改变到区间[0,2^63-1]$

 #define _CRT_SECURE_NO_WARNINGS
#include <climits>
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
string A, B, C; int main()
{
int N;
cin >> N;
for (int i = ; i <= N; i++)
{
long long A, B, C;
cin >> A >> B >> C;
long long num = A + B;
if (A > && B > && num < )
printf("Case #%d: true\n", i);
else if (A < && B < && num >= )
printf("Case #%d: false\n", i);
else if(num > C)
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分) 测试点3 别用cin

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

  5. 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 ...

  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) 【大数加法】

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

  8. 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 ...

  9. 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. 2020 webstorm 最新激活方式 有效期2021年11月 可用

    MIIElT25XE-eyJsaWNlbnNlSWQiOiJPUVQzT0oyNVhFIiwibGljZW5zZWVOYW1lIjoi5rC45LmF5r+A5rS7IGlkZWEubWVkZW1pb ...

  2. django 知识点小结

    以下内容为用django写blog中的一些知识点,权当复习. 一.定义view 1.get_object_or_404()是用get()查询数据,如果不存在就直接返回404 参数: get_objec ...

  3. Redis07——Redis到底能用在什么地方(下)

    在前一篇文章中,我们已经介绍过Redis的一些实际应用.如KV缓存.分布式锁.消息队列,由于篇幅原因,并未介绍完全.接下来将继续为各位带来Redis的更多应用. bitmat(位图) 实现 位图的基本 ...

  4. C# Socket编程实现简单的局域网聊天器

    目录 前言 编码 服务端监听接口 客户端连接接口 文字发送接口 文件发送接口 信息接收接口(文字与文件) 使用 注意事项 源码 前言 最近在学习C# Socket相关的知识,学习之余,动手做了一个简单 ...

  5. $props, $attrs,$listeners的具体使用例子

    我在这使用属性重新render饿了么ui的tree: <el-tree ref="tree" icon-class="fa fa-caret-right" ...

  6. tersserorc的简单使用

    tesserocr 是 python 的一个 OCR 库,它是对 tesseract 做的一层 Python API 封装,所以他的核心是tesseract. tesseract 的安装见 https ...

  7. Linux进程间通信-eventfd

    Linux进程间通信-eventfd eventfd是linux 2.6.22后系统提供的一个轻量级的进程间通信的系统调用,eventfd通过一个进程间共享的64位计数器完成进程间通信,这个计数器由在 ...

  8. 【简说Python WEB】Flask应用的文件结构

    目录 [简说Python WEB]Flask应用的文件结构 1.文件结构的目录 2.配置程序--config.py 3.app应用包 4.剥离出来的email.py 5.蓝本(BLueprint)的应 ...

  9. shell脚本基础-四种启动方式

    1.当前路径启动 ./test.sh 2.绝对路径启动 pwd /data/beijing 'pwd'/test.sh 3.指定解释器执行 sh test.sh bash test.sh 4.shel ...

  10. 【简说Python WEB】pyechart在flask中的应用

    个人笔记总结,可读性不高.只为自己总结用.怕日后忘记. 这里用到了tushare,pandas等python组件. pyechart的案例 c = ( Bar() .add_xaxis([" ...