09年6月5日


1457.   Beat the Spread!

这个题很诡异,看半天题目看不懂啥要求。。。GOOGLE翻译的更是让我一头雾水。。。哎,看代码再看题目就懂了

#include<iostream>

using namespace std;

int main(){

int star=0;

int s=0,d=0;

int a=0,b=0;

cin>>star;

for(int i=0;i<star;i++){

cin>>s>>d;

        a=(s+d)/2;

b=(s-d)/2;

if(a < 0 || b < 0 || d < 0 || s < 0 || s < d || (s%2+d%2)%2 != 0) 

cout<<"impossible"<<endl;

        else cout<<a<<" "<<b<<endl;

}

return 0;

posted @ 2009-06-05 16:52  不做打工仔  阅读(131)  评论(0编辑  收藏  举报