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