# Simpler Way to Solve This Diophantine Equation

In a pet shop, rats cost $5$ dollars each, guppies cost $3$ dollars each, and crickets cost $10$ cents each. $100$ animals are sold, and the total cost is $100$. How many rats, guppies, and crickets were sold?

Our math team coach has shown us the solution already, but her solution requires $7$ different variables and takes at least $10$ minutes for me to solve. The math team contest has $6$ diophantine equations problems of increasing difficulty. I only have $40$ minutes to complete these $6$ questions and I am not allowed to use a calculator.

What is the fastest or simplest way to solve this problem without a calculator?

HINT

$$50r + 30g + c = 1000\tag{1}$$ $$r+g+c = 100\tag{2}$$

Eliminating one variable gives you a linear diophantine equation in two variables whose solution is straightforward. $$49r + 29g = 900 \tag{3}$$

Another approach which works well for this specific problem is :

$$r = \dfrac{900 - 29g}{7\times 7}$$

Since $900$ leaves a remainder of $4$ when divided by $7$,
$29g$ must also leave the remainder $4$ for $r$ to be an integer : $$29g \equiv 4 \pmod 7 \implies g \equiv 4 \pmod 7$$

Plugging in $g=4$ gives you $r=16$. This is one solution.

• Sorry, I don't really understand still. I got 49r+29g=900 and solving for r gets me r=(900-29g)/49. Where do I go from here? Sep 21, 2014 at 22:46
• The goal here is to find a positive integer solution for $r$ and $g$. One way is to use the standard method for solving linear diophantine equations. Familiar with euclidean algorithm for finding gcd ? Sep 21, 2014 at 22:50
• @Alzeon - I have updated the answer with a simpler method that doesn't use euclid algorithm. Check it out :) Sep 21, 2014 at 23:17