A + B Is Overflow

来源:互联网 发布:查询mysql数据库ip 编辑:程序博客网 时间:2024/05/21 14:58

Description

Judge whether the sum of A and B will exceed the range of 32-bit signed integer.

Input

There are multiple test cases. 

The first line of each test case is a positive integer T, indicating the number of test cases. 

For each test case, there is only one line including two 32-bit signed integers A and B.

Output

For each test case, output one line.

 If the sum of A and B will exceed the range of integer, print "Yes", else print "No".

Sample Input
31 2-2147483648 21474836472147483647 2147483647
Sample Output
NoNoYes
#include<stdio.h>
int main()
{
int t,a,b;
while(~scanf("%d",&t))
  {
 while(t--)
 {
scanf("%d%d",&a,&b);
if(a>0&b>0&&a+b<=0||a<0&&b<0&&a+b>=0)
 {
 printf("Yes\n");
 }
else{
 printf("No\n");
}
}
}
 return 0;

}

0 0