Let $ABC$ be an [equilateral triangle](https://artofproblemsolving.com/wiki/index.php/Equilateral_triangle), and let $D$ and $F$ be [points](https://artofproblemsolving.com/wiki/index.php/Point) on sides $BC$ and $AB$, respectively, with $FA = 5$ and $CD = 2$.  Point $E$ lies on side $CA$ such that [angle](https://artofproblemsolving.com/wiki/index.php/Angle) $DEF = 60^{\circ}$.  The area of triangle $DEF$ is $14\sqrt{3}$.  The two possible values of the length of side $AB$ are $p \pm q \sqrt{r}$, where $p$ and $q$ are rational, and $r$ is an [integer](https://artofproblemsolving.com/wiki/index.php/Integer) not divisible by the [square](https://artofproblemsolving.com/wiki/index.php/Square) of a [prime](https://artofproblemsolving.com/wiki/index.php/Prime).  Find $r$.
[AIME I 2007-15.png](https://artofproblemsolving.com/wiki/index.php/File:AIME_I_2007-15.png)
Denote the length of a side of the triangle $x$, and of $\overline{AE}$ as $y$. The area of the entire equilateral triangle is $\frac{x^2\sqrt{3}}{4}$. Add up the areas of the triangles using the $\frac{1}{2}ab\sin C$ formula (notice that for the three outside triangles, $\sin 60 = \frac{\sqrt{3}}{2}$): $\frac{x^2\sqrt{3}}{4} = \frac{\sqrt{3}}{4}(5 \cdot y + (x - 2)(x - 5) + 2(x - y)) + 14\sqrt{3}$. This simplifies to $\frac{x^2\sqrt{3}}{4} = \frac{\sqrt{3}}{4}(5y + x^2 - 7x + 10 + 2x - 2y + 56)$. Some terms will cancel out, leaving $y = \frac{5}{3}x - 22$.
$\angle FEC$ is an [exterior angle](https://artofproblemsolving.com/wiki/index.php/Exterior_angle) to $\triangle AEF$, from which we find that $60 + \angle CED = 60 + \angle AFE$, so $\angle CED = \angle AFE$. Similarly, we find that $\angle EDC = \angle AEF$. Thus, $\triangle AEF \sim \triangle CDE$. Setting up a [ratio](https://artofproblemsolving.com/wiki/index.php/Ratio) of sides, we get that $\frac{5}{x-y} = \frac{y}{2}$. Using the previous relationship between $x$ and $y$, we can solve for $x$.


$xy - y^2 = 10$
$\frac{5}{3}x^2 - 22x - \left(\frac{5}{3}x - 22\right)^2 - 10 = 0$
$\frac{5}{3}x^2 - \frac{25}{9}x^2 - 22x + 2 \cdot \frac{5 \cdot 22}{3}x - 22^2 - 10= 0$
$10x^2 - 462x + 66^2 + 90 = 0$


Use the [quadratic formula](https://artofproblemsolving.com/wiki/index.php/Quadratic_formula), though we only need the root of the [discriminant](https://artofproblemsolving.com/wiki/index.php/Discriminant). This is $\sqrt{(7 \cdot 66)^2 - 4 \cdot 10 \cdot (66^2 + 90)} = \sqrt{49 \cdot 66^2 - 40 \cdot 66^2 - 4 \cdot 9 \cdot 100}$$= \sqrt{9 \cdot 4 \cdot 33^2 - 9 \cdot 4 \cdot 100} = 6\sqrt{33^2 - 100}$. The answer is $\boxed{989}$.