UVa 10812 – Beat the Spread!

#include <iostream>

using namespace std;

int main(){
   int sum,dif,tc;
   cin>>tc;
   while (tc--){
       cin>>sum>>dif;

       if (dif>sum || ((sum^dif)&1)) // one odd and other even
           cout<<"impossible"<<endl;

       else {
           dif = (sum+dif)/2;
           cout<<dif<<" "<<sum-dif<<endl;
       }

   }
   return 0;
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s