您的位置:首页 > 其它

zoj 2388.Beat the Spread!

2012-11-05 23:37 447 查看
Beat the Spread!

#include <fstream>
#include <iostream>
#include <cmath>
using namespace std;
int main(int argc, char* argv[])
{
//	ifstream cin("aaa.txt");
int n,x,y,a,b;
cin>>n;//不理会第一个数字
while(cin>>a>>b)
{
//和比差小,不成立
if(a<b)
{
cout<<"impossible"<<endl;
continue;
}
//分数只能是自然数(包括0)
if((a+b)%2!=0 || abs(a-b)%2!=0)
{
cout<<"impossible"<<endl;
continue;
}
x=abs((a+b)/2);
y=abs((a-b)/2);
if(x>y)
cout<<x<<" "<<y<<endl;
else
cout<<y<<" "<<x<<endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: