You are making this a bit more complicated than it needs to be.
Furthermore, it is not given that the roots are rational numbers, so there is no guarantee that the rational root theorem will help.
The fact that the second order equation has the same roots means that P(x) can be factorized into:
P(x) = (x - A)(x2+ 5x + K)
If you multiply this and equate each coefficient to the coefficients of P(x), what do you get?