Megan and Shana race against each other with the winner of each race receiving $x$ gold coins and the loser receiving $y$ gold coins. (There are no ties and $x$ and $y$ are integers with $x>y>0$.) After several races, Megan has 42 coins and Shana has 35 coins. Shana has won exactly 2 races. The value of $x$ is
(A) 3
(B) 7
(C) 5
(D) 6
(E) 4
Suppose that Megan and Shana competed in exactly $n$ races.

Since Shana won exactly 2 races, then Megan won exactly $n-2$ races.

Since Shana won 2 races and lost $n-2$ races, then she received $2 x+(n-2) y$ coins.

Thus, $2 x+(n-2) y=35$.

Since Megan won $n-2$ races and lost 2 races, then she received $(n-2) x+2 y$ coins.

Thus, $(n-2) x+2 y=42$.

If we add these two equations, we obtain $(2 x+(n-2) y)+((n-2) x+2 y)=35+42$ or $n x+n y=77$ or $n(x+y)=77$.

Since $n, x$ and $y$ are positive integers, then $n$ is a positive divisor of 77 , so $n=1,7,11$ or 77 .

Subtracting $2 x+(n-2) y=35$ from $(n-2) x+2 y=42$, we obtain

$$
((n-2) x+2 y)-(2 x+(n-2) y)=42-35
$$

or $(n-4) x+(4-n) y=7$ or $(n-4)(x-y)=7$.

Since $n, x$ and $y$ are positive integers and $x>y$, then $n-4$ is a positive divisor of 7 , so $n-4=1$ or $n-4=7$, giving $n=5$ or $n=11$.

Comparing the two lists, we determine that $n$ must be 11 .

Thus, we have $11(x+y)=77$ or $x+y=7$.

Also, $7(x-y)=7$ so $x-y=1$.

Adding these last two equations, we obtain $(x+y)+(x-y)=7+1$ or $2 x=8$, and so $x=4$. (Checking, if $x=4$, then $y=3$. Since $n=11$, then Megan won 9 races and Shana won 2 races. Megan should receive $9(4)+2(3)=42$ coins and Shana should receive $2(4)+9(3)=35$ coins, which agrees with the given information.)