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

题意:

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

trick:

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

AAAAAccepted code:

 1 #define HAVE_STRUCT_TIMESPEC
 2 #include<bits/stdc++.h>
 3 using namespace std;
 4 int main(){
 5     ios::sync_with_stdio(false);
 6     cin.tie(NULL);
 7     cout.tie(NULL);
 8     int t;
 9     cin>>t;
10     for(int i=1;i<=t;++i){
11         if(i!=1)
12             cout<<"\n";
13         long long a,b,c;
14         cin>>a>>b>>c;
15         long long x=a+b;
16         if(a>0&&b>0&&x<0){
17             cout<<"Case #"<<i<<": true";
18             continue;
19         }
20         else if(a<0&&b<0&&x>=0){
21             cout<<"Case #"<<i<<": false";
22             continue;
23         }
24         long long d=a+b;
25         if(d>c)
26             cout<<"Case #"<<i<<": true";
27         else
28             cout<<"Case #"<<i<<": false";
29     }
30     return 0;
31 }

 

 

 

posted @ 2019-10-30 08:20  sewage  阅读(355)  评论(0编辑  收藏  举报