If $a + b = 20$, then what is the maximum value of $ab^2$? Knowing that
$$a + b = 20$$
and $a,b \in \mathbb{Z}_{+}$
What is the maximum value that $ab^2$ can take?
If $b$ is even then so is $a$. Hence, let $b = 2k$ and $a = 20 - 2k$, where $k \in \{1, 2, 3, \cdots, 9\}$
$$ab^2 = (20 - 2k)(2k)^2 = 80k^2 - 8k^3$$
The value of $k$ which maximizes $ab^2$ is therefore $k = 7$ which gives $ab^2 = 1176$.
However this only shows that this is the maximum for even values of $a$ and $b$. It turns out that the maximum of $ab^2$ is when both are odd. 
How do I solve this question since my approach is clearly not very elegant? 
My solution:
$$a = 20 - b \Longrightarrow ab^2 = (20 - b)b^2$$
Differentiate to find the maximum value of $b$
$$40b - 3b^2 = b(40-3b) = 0$$ 
$$\Longrightarrow b = \left\lfloor \frac{40}{3} \right\rfloor$$ $$\Longrightarrow b = \left\lceil \frac{40}{3} \right\rceil$$
Therefore $a, b = 7, 13$ or $a, b = 6, 14$. Inspecting these $2$ cases yields the former.
So the maximum value $ab^2$ can take is $1183$.
 A: If $a$ and $b$ are required to be positive, but not integers, then the AM-GM says that
$$
\frac{a+\frac b2+\frac b2}3\geq\sqrt[3]{a\cdot\frac b2\cdot\frac b2}
$$
with equality iff $a=\frac b2=\frac b2$. For $a,b$ integers, you just have to try the integers closest to this equality (i.e. $a=6$ and $a=7$).
A: By AM-GM 
\begin{eqnarray*}
\frac{1}{3} \left( a + \frac{b}{2} +\frac{b}{2} \right) \geq \sqrt[3]{\frac{ab^2}{4}}.
\end{eqnarray*}
So 
\begin{eqnarray*}
4 \left( \frac{20}{3} \right)^3 \geq ab^2.
\end{eqnarray*}
Now the restriction that $a$ and $b$ are integers suggest $(a,b)=(6,14)$ or $(7,13)$ computing these gives $(a,b)=(7,13)$ and a largest value of $1183$.
A: Comment: Let $p = ab^2.$ For integers, it is neither imaginative nor difficult to try all possibilities:
   a  b    p
   1 19  361
   2 18  648
   3 17  867
   4 16 1024
   5 15 1125
   6 14 1176
   7 13 1183  # <-----
   8 12 1152
   9 11 1089
  10 10 1000
  11  9  891
  12  8  768
  13  7  637
  14  6  504
  15  5  375
  16  4  256
  17  3  153
  18  2   72
  19  1   19

