Finding the required value of an algebric expression
This is classical Integer Linear Programming. You have the following problem:

$$\begin{align}
Ax+Bx+Cx &amp; \to \max \\
\text{s.t} \quad x,y,z &amp;\ge 0\\
Ax+Bx+Cx &amp;\le T \\
x,y,z &amp;\in \mathbb{Z}\\
\end{align}$$

There are several algorithms available for such problems. Google "branch and bound" or "branch and cut" and you will get to them. 

You can picture your problem as follows. Your variables $x,y,z$ decode a grid point in 3d. The constraints cut of hyperplanes, which keeps you left with a  set of candidate solutions. In your example this set is finite. You could basically test out all cancidates brute force. But it is more practical to add additional constraints to make the candidate set smaller - or in other words you filter out points. If you relax the condition that $x,y,z$ are integers, then the problem becomes much easier (Linear Programm), because then you know that the optimal point you are looking for is on some "corner" of your candidate set.