Skip to main content

UVA 10812(Beat the Spread)

Superbowl Sunday is nearly here. In order to pass the time waiting for the half-time commercials and wardrobe malfunctions, the local hackers have organized a betting pool on the game. Members place their bets on the sum of the two final scores, or on the absolute difference between the two scores. Given the winning numbers for each type of bet, can you deduce the final scores?

Input
The first line of input contains n, the number of test cases. n lines follow, each representing a test case. Each test case gives s and d, non-negative integers representing the sum and (absolute) difference between the two final scores.

Output
For each test case, output a line giving the two final scores, largest first. If there are no such scores, output a line containing “impossible”. Recall that football scores are always non-negative integers.

Sample Input
2
40 20
20 40
Sample Output
30 10
 impossible






#include<iostream>
#include<cstdio>
#include<math.h>
#include<cstdlib>
using namespace std;
int main()
{
    int a,b,c,sum,d,T;
    cin>>T;
    while(T--){

    cin>>a>>b;
    if(a>=b && (a+b)%2==0)
    {
        sum=(a+b)/2;
        d=(a-b);
        d/=2;
        cout<<sum<<" "<<d<<endl;
}
    else
        cout<<"impossible"<<endl;
    }
return 0;
}

Comments

Popular posts from this blog

**Competitive Programming এর জন্য কি কি শিখতে হবে...**

link: https://github.com/me-shaon/bangla-programming-resources -------------------------------------------------------------------------------------------------------------------------- এলগোরিদম ব্যাসিক বিগ "O" নোটেশন  -  শাফায়েত আশরাফ কমপ্লেক্সিটি ক্লাস(P-NP, টুরিং মেশিন ইত্যাদি)  -  শাফায়েত আশরাফ ডাটা স্ট্রাকচার অ্যাারে (Array) অ্যারে ব্যাসিক অপারেশন  -  হাসান আবদুল্লাহ অ্যারে কমপ্রেশন/ম্যাপিং  -  শাফায়েত আশরাফ লিংকড লিস্ট (Linked List) লিংকড লিস্ট  -  শাফায়েত আশরাফ লিংকড লিস্ট ব্যাসিক অপারেশন  -  হাসান আবদুল্লাহ লিংকড লিস্ট  -  অনিন্দ্য পাল লিংকড লিস্ট – সি  -  মুনতাসির ওয়াহেদ ডাটা স্ট্রাকচার ও লিংকড লিস্ট  -  আলাভোলা কোডিং লিংকড লিস্ট  -  আলাভোলা ডাবলি লিংকড লিস্ট  -  মুনতাসির ওয়াহেদ স্ট্যাক (Stack) স্ট্যাক  -  শাফায়েত আশরাফ স্ট্যাক ব্যাসিক অপারেশন  -  হাসান আবদুল্লাহ স্ট্যাক বেসিক ডাটা স্ট্রাকচার  -  আহম...

codeforce problemset 758A solved

A. Holiday Of Equality time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are  n  citizens, the welfare of each of them is estimated as the integer in  a i  burles (burle is the currency in Berland). You are the royal treasurer, which needs to count the minimum charges of the kingdom on the king's present. The king can only give money, he hasn't a power to take away them. Input The first line contains the integer  n  ( 1 ≤  n  ≤ 100 ) — the number of citizens in the kingdom. The second line contains  n  integers  a 1 ,  a 2 , ...,  a n , where  a i  ( 0 ≤  a i  ≤ 10 6 ) — the welfare of the  i -th citizen. Output In the only li...

700 problems to understand you complete algorithmic programming.

700 problems to understand you complete algorithmic programming. 1. Segment Tree: To Read : http://www.topcoder.com/tc?d1=tutorials&d2=lowestCommonAncestor&module=Static http://ronzii.wordpress.com/2011/07/08/segment-tree-tutorial/ http://se7so.blogspot.in/2012/12/segment-trees-and-lazy-propagation.html http://olympiad.cs.uct.ac.za/presentations/camp3_2007/interval_trees.pdf http://codeforces.com/blog/entry/6281 http://apps.topcoder.com/forums/?module=Thread&threadID=651820&start=0&mc=2#1146133 http://www.algorithmist.com/index.php/Segmented_Trees http://letuskode.blogspot.in/2013/01/segtrees.html http://wcipeg.com/wiki/Heavy-light_decomposition http://discuss.codechef.com/questions/5960/rnestescape-from-the-mines http://ideone.com/dPS5N  (Heavy Light implementation). https://sites.google.com/site/indy256/algo/heavy_light  (Heavy Light implementation). Problems: http://www.spoj.com/problems/GSS1 http://www.spoj.com/problems/GSS2 http://www.spoj.com...