POJ 2301 Beat the Spread!

太水了。。稍微注意下判断就好了。。

#include <cstdio>
#include <cmath>
using namespace std;
int main(){
	int nCase;
	scanf("%d",&nCase);
	while(nCase--){
		int s=0,d=0,r1,r2;
		scanf("%d%d",&s,&d);
		if(s<d||s%2==0&&d%2==1||s%2==1&&d%2==0){
			printf("impossible\n");
			continue;		
		}
		r1=(s+d)/2;
		r2=(s-d)/2;
		r2=r2>0?r2:-r2;
		printf("%d %d\n",r1,r2);		
	}
	return 0;
}


 

你可能感兴趣的:(POJ 2301 Beat the Spread!)