I'm trying to solve this polynomial Diophantine equation for $R$ and $S$:
$ AR + BS = G $
where
$A(x) = a_0x^{n_a} + a_1x^{n_a-1} + a_2x^{n_a-2} + ... + a_{n_a}$
$B(x) = b_0x^{n_b} + b_1x^{n_b-1} + b_2x^{n_b-2} + ... + b_{n_b}$
$R(x) = r_0x^{n_r} + r_1x^{n_r-1} + r_2x^{n_r-2} + ... + r_{n_r}$
$S(x) = s_0x^{n_s} + s_1x^{n_s-1} + s_2x^{n_s-2} + ... + s_{n_s}$
$G(x) = g_0x^{n_g} + g_1x^{n_g-1} + g_2x^{n_g-2} + ... + g_{n_g}$
Suppose that the polynomial degrees ($n_a$, $n_b$, $n_r$, $n_s$ and $n_g$) are chosen so that there is always at least one solution.
Is there any algorithm or method for this? I'm a computer programmer, and I'm going to implement this solution method by C++ code. I don't want to be lost in Mathematics; so please guide me to an easy-to-understand and practical method.