题意:
输入三个整数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