当前位置:网站首页>Pat 1065 a+b and C (64bit) (20 points) (16 points)
Pat 1065 a+b and C (64bit) (20 points) (16 points)
2022-07-01 14:26:00 【Python ml】
because A、B Of ⼤⼩ by [-2^63, 2^63],⽤long long Storage A and B Value , And the value they add sum:
If A > 0, B < 0 perhaps A < 0, B > 0,sum It is impossible to overflow
If A > 0, B > 0,sum It might spill over ,sum The scope should be (0, 2^64 – 2], The result of overflow should be [-2^63, -2]
It's a negative number , therefore sum < 0 It means overflow
If A < 0, B < 0,sum It might spill over , Empathy ,sum The result of overflow is ⼤ On 0 Of , therefore sum > 0 It means that it overflows
#include <iostream>
using namespace std;
int main() {
int n;
cin>>n;
for(int i=0;i<n;i++){
long long a,b,c;
cin>>a>>b>>c;
long long sum=a+b;
if(a>0&&b>0&&sum<0){
printf("Case #%d: true\n", i + 1);
} else if(a < 0 && b < 0 && sum >= 0){
printf("Case #%d: false\n", i + 1);
} else if(sum > c) {
printf("Case #%d: true\n", i + 1);
} else {
printf("Case #%d: false\n", i + 1);
}
}
return 0;
}
边栏推荐
- 111. Minimum depth of binary tree
- Research Report on the development trend and competitive strategy of the global display filter industry
- 佩服,阿里女程序卧底 500 多个黑产群……
- 博文推荐 | 深入研究 Pulsar 中的消息分块
- SWT / anr problem - how to capture performance trace
- Websocket (simple experience version)
- In depth cooperation | Taosi data cooperates with changhongjia Huawei customers in China to provide tdengine with powerful enterprise level products and perfect service guarantee
- Basic knowledge of C language
- Research Report on the development trend and competitive strategy of the global aviation leasing service industry
- C language ordering management system
猜你喜欢

Play with mongodb - build a mongodb cluster

开源实习经验分享:openEuler软件包加固测试

WebSocket(简单体验版)

Logic is a good thing

Open source internship experience sharing: openeuler software package reinforcement test

Après avoir été licencié pendant trois mois, l'entrevue s'est effondrée et l'état d'esprit a commencé à s'effondrer.

户外LED显示屏应该考虑哪些问题?

【R语言数据科学】:机器学习常见评估指标

Vnctf2022 open web gocalc0

sqlilabs less13
随机推荐
Don't want to knock the code? Here comes the chance
[NLP] pre training model - gpt1
Use the right scene, get twice the result with half the effort! Full introduction to the window query function and usage scenarios of tdengine
【商业终端仿真解决方案】上海道宁为您带来Georgia介绍、试用、教程
Basic operation of queue (implemented in C language)
数据湖系列之一 | 你一定爱读的极简数据平台史,从数据仓库、数据湖到湖仓一体
户外LED显示屏应该考虑哪些问题?
sqlilabs less13
How to pass array parameters in get request
sqlilabs less-8
Basic knowledge of C language
Use of Oracle database objects
Research Report on the development trend and competitive strategy of the global diamond suspension industry
我们该如何保护自己的密码?
Research Report on the development trend and competitive strategy of the global powder filling machine industry
Research Report on the development trend and competitive strategy of the global display filter industry
WebSocket(简单体验版)
Go integrates logrus to realize log printing
[flask] flask starts and implements a minimal application based on flask
Leetcode (69) -- square root of X