2013
12-29

# Has the sum exceeded

As we all know, in the computer science, an integer A is in the range of 32-signed integer, which means the integer A is between -2^31 and (2^31)-1 (inclusive), and A is a 64-signed integer, which means A is between -2^63 and (2^63)-1(inclusive). Now we give the K-signed range, and two K-signed integers A and B, you should check whether the sum of A and B is beyond the range of K-signed integer or not.

There will be many cases to calculate. In each case, there comes the integer K (2<=K<=64) first in a single line. Then following the line, there is another single line which has two K-signed integers A and B.

There will be many cases to calculate. In each case, there comes the integer K (2<=K<=64) first in a single line. Then following the line, there is another single line which has two K-signed integers A and B.

32
100 100

WaHaHa

http://acm.hdu.edu.cn/showproblem.php?pid=2116

#include <stdio.h>
int k;
__int64 a,b;
__int64 pow(int x,int y)
{
int i;
__int64 s=1;
for(i=0;i<y;i++)
s*=x;
return s;
}
#define MAX pow(2,63)
int test()
{
__int64 max,min;
if(k==64)min=-MAX,max=MAX-1;
else
min=-MAX>>k,max=(MAX>>k)-1;
if(a==0&&b==0)return 0;
if(a>0&&b<0)return 0;
if(a<0&&b>0)return 0;
if(a>0)
return (max-a)<b;
return (min-a)>b;
}
int main()
{
while(~scanf("%d",&k))
{
scanf("%I64d%I64d",&a,&b);
printf(test()?"Yes\n":"WaHaHa\n");
}
return 0;
}

1. Good task for the group. Hold it up for every yeara??s winner. This is a excellent oppotunity for a lot more enhancement. Indeed, obtaining far better and much better is constantly the crucial. Just like my pal suggests on the truth about ab muscles, he just keeps obtaining much better.