# UVa 10812

## Summary

This is a pretty standard formula manipulation math problem.

## Explanation

Given the sum of a and b, and the difference of a and b, find a and b. First, make sure the difference is not greater than the sum, since this would imply one of them is negative. Without a lost of generality, assume ${\displaystyle a\geq b}$. We get

${\displaystyle a+b=s}$ and ${\displaystyle a-b=d}$.

Solving for a in terms of b, we get: ${\displaystyle a=s-b}$

plugging it into the latter equation:

${\displaystyle s-b-b=d}$

or

${\displaystyle s-d=2b}$

We then solve for b numerically and plug it into one of the formulas to get a. All that's left is to check that a and b are both non-negative, and we're done.

NOTE: Check that ${\displaystyle (s+d)}$ and ${\displaystyle (s-d)}$ are both divisible by 2. :-)

```8
40 20
20 40
1 5
100 6
12 61
51 61
123 512
63 1
```

```30 10
impossible
impossible
53 47
impossible
impossible
impossible
32 31
```