There are two things I don't understand about this.

First, what exactly is your question? Your f(x) has no bearing on this problem.

Second, the given solution, p = -1, q = -20, is not a possible solution because \(\displaystyle x^3 - x^2 - 20 = 0\) also has no bearing on this problem.

The only function that can be written as \(\displaystyle f(x) = x^2\) is, well, \(\displaystyle x^2\) itself.

Is there more to this problem?

-Dan