Diophantine word problem A farmer purchased $100$ head of livestock for a total cost of $4000$. Prices were as follows: calves, $120$ each; lambs, $50$ each; piglets, $25$ each. If the farmer bought at least one animal of each type, how many of each did he buy? (Give all possible solutions.)
Can someone come up with the diophantine equation to get me started? I'm just a little confused because I have the total number and total cost...
 A: This is how I would go about solving the problem:
Step 1 - Equations:
$C + L + P = 100 \tag{1}$
$120 \cdot C + 50 \cdot L + 25 \cdot P = 4000 \tag{2}$
where $C, L, P$ are the number of Calves, Lambs and Pigs respectively.
Solving for $C$ and $L$ (in terms of $P$)$^1$ tells us that all possible solutions will be of the form $(C, L, P) = \left(\frac{5P - 200}{14}, \frac{1600-19P}{14}, P\right) \tag{3}$
Step 2 - Constraints: These will put a restriction on the values $P$ can take, and thus on the possible solutions represented by $(3)$.
$C, L, P \ge 1 \tag{A}$
$C, L, P \in \mathbb{Z} \tag{B}$
From $(A)$ we get the first set of restrictions:
$\begin{matrix} & \frac{5P - 200}{14} \ge 1, & \frac{1600-19P}{14} \ge 1, & P \ge 1 \\ \implies & P \ge 42.8, & P \le 83.47, & P \ge 1 \end{matrix}$
$\therefore P \in [42.8, 83.47] \tag{4}$
From $(B)$ we get the second set of restrictions:
$\begin{matrix} & \frac{5P - 200}{14} = k_1, & \frac{1600-19P}{14} = k_2, & P \in \mathbb{Z} \\ \implies & P = 14\left(\frac{k_1}{5}\right) + 40, & \text{redundant}, & P \in \mathbb{Z} \end{matrix}$
$\therefore P = 14k + 40 \tag{5}$
where $k_1, k_2 \in \mathbb{Z}$ and $k = (k_1 / 5) \in \mathbb{Z}$ so as to satisfy $P \in \mathbb{Z}$. Notice that I marked the integer constraint on $L$ as redundant, since it automatically follows from $(1)$ if $C, P$ are integers.
Combining $(4) \text{ and } (5)$ gives $P \in \{54, 68, 82 \} \tag{6}$
Step 3 - Solutions: Substituting into $(3)$ gives us all possible solutions.
$$\begin{matrix}C & L & \color{#000080}{P} \\ 5 & 41 & \color{#000080}{54} \\ 10 & 22 & \color{#000080}{68} \\ 15 & 3 & \color{#000080}{82}\end{matrix}$$
$^1$Note you can also solve for $L, P$ in terms of $C$ or $C, P$ in terms of $L$ and follow a similar approach.
A: Suppose he bought C calves, L lambs, and P piglets.
Then we would have:
$$C+L+P=100$$
$$120C+50L+25P=4000$$
$$C,L,P \ge 1$$
Substitute the 1st equation in the 2nd to find the equation to solve.
