现在的位置: 首页 > 综合 > 正文

zoj 2388 Beat the Spread!

2013年06月21日 ⁄ 综合 ⁄ 共 382字 ⁄ 字号 评论关闭
#include "iostream"
#include "math.h"
#include<stdlib.h>
using namespace std;

int main()
{
	int TestCase;
	cin >> TestCase;
	while (TestCase--)
	{
		int s1, s2, ans1, ans2;
		cin  >> s1 >> s2;
		if (s1 < s2)
			cout << "impossible" << endl;
		else if ((s1 + s2) % 2 == 1)//没有考虑到这种情况,所以WA了两次!因为分数都是10的!
			cout << "impossible" << endl;
		else
		{
			ans1 = (s1 + s2) / 2;
			ans2 = abs(int(s1 - s2)) / 2;
			if (ans1 > ans2)
				cout << ans1  << " " << ans2 << endl;
			else
				cout << ans2 << " " << ans2 << endl;
		}
	}
}

 

抱歉!评论已关闭.