Pages

Saturday, September 19, 2009

UVA Problem#10812

Question:
http://uva.onlinejudge.org/external/108/10812.html 

Solution:
1. run the loop down to n
2. take the input s and d.
3. Print the output using this technique:        
if(s<d || (s+d)%2 || (s-d)%2)
            printf("impossible\n");
        else{
            a=(s+d)/2;
            b=(s-a);
            if(a>b)
                printf("%d %d\n", a, b);
            else
                printf("%d %d\n", b, a);
        }