Better algorithm, limiting the number of loops by only using c values
which yield a total (given a + b) of 1000.