您的位置:首页 > 其它

UVa 10812 - Beat the Spread!

2012-11-14 13:52 369 查看
题目:已知 a+b,a-b计算a,b。

分析:简单题。

注意:a+b<a-b || 2a%2{||2b%2} 时不合法 。因为a+b,a-b为整,所以2a,2b同奇偶。

#include <stdio.h>
#include <stdlib.h>

int main()
{
	int N,B,S;
	while ( scanf("%d",&N) != EOF ) 
	while ( N -- ) {
		scanf("%d%d",&B,&S);
		if ( B < S || (B+S)%2 ) 
			printf("impossible\n");
		else 
			printf("%d %d\n",(B+S)/2,(B-S)/2);
	}
	return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: