首页 > 其他 > 详细

【PAT甲级】1065 A+B and C (64bit) (20 分)(大数溢出)

时间:2019-10-30 09:52:30      阅读:142      评论:0      收藏:0      [点我收藏+]

题意:

输入三个整数A,B,C(long long范围内),输出是否A+B>C。

trick:

测试点2包括溢出的数据,判断一下是否溢出即可。

代码:

#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin>>t;
for(int i=1;i<=t;++i){
if(i!=1)
cout<<"\n";
long long a,b,c;
cin>>a>>b>>c;
long long x=a+b;
if(a>0&&b>0&&x<0){
cout<<"Case #"<<i<<": true";
continue;
}
else if(a<0&&b<0&&x>=0){
cout<<"Case #"<<i<<": false";
continue;
}
long long d=a+b;
if(d>c)
cout<<"Case #"<<i<<": true";
else
cout<<"Case #"<<i<<": false";
}
return 0;
}

【PAT甲级】1065 A+B and C (64bit) (20 分)(大数溢出)

原文:https://www.cnblogs.com/ldudxy/p/11762743.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!