# Given perimeter of triangle and one side, find other two sides

In triangle ABC, all three sides have integer lengths. If AB = 21, the perimeter is 54, and the area is a positive integer, what are the lengths of BC and AC?

I tried using Heron's Formula, but I couldn't really get anywhere. Any suggestions? This question was in my Math Challenge II Number Theory packet.

• Heron's formula will go wild. Draw a height, it will be much nicer. – chubakueno May 8 '14 at 1:22

If the area is an integer, the height to $AB$ has to be an even integer, and because the other sides are an integer, it has to be a member of two different pythagorean triangles (since we can't divide $21$ in a half). $8,12$ are possible candidates then.$12$ works:
$$12^2+5^2=13^2,12^2+16^2=20^2, 13+20+21=54$$
In $$\text{area}^2 = \frac{1}{16}(a+b+c)(-a+b+c)(a-b+c)(a+b-c)$$ you know $c=21$ and $a+b+c=54$, so that $b=33-a$. So, the above becomes \begin{align} \text{area}^2 &= \frac{1}{16}(54)(54-2a)(2a-12)(12) \\[4pt] &= 2\cdot 3^4 \cdot (27-a)(a-6) \end{align} Thus, $a$ is somewhere between $6$ and $27$. Since the right-hand side needs to be a perfect square, the factors $(27-a)$ and $(a-6)$ need to contribute an odd number of $2$s, and an even number of any other prime, to the factorization. You can tick through cases pretty quickly, using the latter fact to instantly weed-out cases with obvious singleton prime factors before expending any real mental energy counting other primes:
$$\begin{array}{rccll} a & (27-a) & ( a - 6 ) & & \\ 7 & 20 & 1 & \text{single } 5\\ 8 & 19 & 2 & \text{single } 19 \\ 9 & 18 & 3 & - & 3^\text{odd} \to \text{nope!}\\ 10 & 17 & 4 & \text{single } 17\\ 11 & 16 & 5 & \text{single } 5\\ 12 & 15 & 6 & \text{single } 5 \\ \color{red}{13} & \color{red}{14} & \color{red}{7} & \color{red}{-} & \color{red}{2^\text{odd} \cdot 7^\text{even} \to \text{yes!}} \\ 14 & 13 & 8 & \text{single } 13\\ 15 & 12 & 9 & - & 3^\text{odd}, 2^\text{even} \to \text{nope!}\\ 16 & 11 & 10 & \text{single } 11 \\ 17 \dots 26 & - & - & \text{don't need to check} & \text{(why?)} \\ \end{array}$$
Therefore, the other sides have length $13$ and $33-13=20$. $\square$