A farmer purchased $100$ head of livestock for a total cost of $\$4000$. Prices were as follow: calves $\$120$ each, lambs $\$50$ each, piglets $\$25$ each. If the farmer obtained at least one animal of each type, how many did he buy?
total number of livestock$=100$,
number of calves$=x$,
number of lambs$=y$,
number of piglets$=z$,
cost of a calf$-120$,
cost of a lamb$-50$,
cost of a piglet$-25$
equations:
1) $x+y+z=100$
2) $120x+50y+25z=4000$
$24x+10y+5z=800$
$24x+10y+5(100-x-y)=800$
$19x+5y=300$
What do I do from here to find the solution? I don't know mods yet..
Best Answer
The answer - I believe it's unique, but it's very late and I'm tired - is $15$ cows, $3$ lambs, and $82$ piglets.
This was my approach.
First, you have a system of two linear equations. The usual thing to do is to try to eliminate some of the variables. Multiply the first equation by $120$ to get $120c+120l+120p=12000$, and subtract the other equation from that to eliminate $c$, leaving $70l+95p=8000$. Dividing by the GCD, we get $14l+19p=1600$, and now we can set up a linear relation between $p$ and $l$:
$$p=\frac{1600-14l}{19}$$
I chose to divide by $19$ and not $14$ because $19$ happens to be prime. This is a good thing because we're now going to work modulo $19$ to determine when the right hand side is an integer. We want $1600-14l\equiv0\mod19$, and since $19$ is prime we get to do division, and find that the only possibility is $l\equiv3$. So:
$$l=19k + 3$$
And, applying the previous relation for $p$ and simplifying:
$$p=14k+82$$
Great, we've expressed $l$ and $p$ in terms of one variable $k$ - we now have a system of two equations in two variables. Plug what we've found back into the original two equations and we get:
$$\begin{align} 33k+85+c&=100\\ 1300k+2200+120c&=4000 \end{align}$$
From which we deduce the solution I gave above.