Prove that the polynomial is $g(x,y)(x^2 + y^2 -1)^2 + c$ This is from a Brazilian math contest for college students (OBMU):
Let $f(x,y)$ be a polynomial in two real variables such that the polynomials 
$$\frac{\partial f}{\partial x}(x,y)$$
$$\frac{\partial f}{\partial y}(x,y)$$
are divisible by $x^2+y^2-1$. Prove that there's a polynomial $g(x,y)$ and a constant $c$ such that
$$f(x,y) = g(x,y)(x^2+y^2 -1)^2 +c$$
 A: Treating $f$ as a polynomial in $(\mathbb{R}[y])[x]$, there exist polynomials $p(x,y) \in (\mathbb{R}[y])[x], q(y), r(y) \in \mathbb{R}[y]$, such that $f(x,y)=(x^2+y^2-1)p(x,y)+xq(y)+r(y)$.
We have that $\frac{\partial f}{\partial x}(x,y)=(x^2+y^2-1)\frac{\partial p}{\partial x}(x,y)+2xp(x,y)+q(y)$ and $\frac{\partial f}{\partial y}(x,y)=(x^2+y^2-1)\frac{\partial p}{\partial y}(x,y)+2yp(x,y)+xq’(y)+r’(y)$ are divisible by $(x^2+y^2-1)$. Therefore $2xp(x,y)+q(y)$ and $2yp(x,y)+xq’(y)+r’(y)$ are divisible by $(x^2+y^2-1)$
As we did earlier, there exist polynomials $s(x,y) \in (\mathbb{R}[y])[x], t(y),u(y) \in \mathbb{R}[y]$ such that $p(x,y)=(x^2+y^2-1)s(x,y)+xt(y)+u(y)$.
We have that 
\begin{align}
2xp(x,y)+q(y)&=2x(x^2+y^2-1)s(x,y)+2x^2t(y)+2xu(y)+q(y) \\
&=(x^2+y^2-1)(2xs(x,y)+2t(y))+x(2u(y))+(q(y)-2(y^2-1)t(y))\\
\end{align}
 is divisible by $x^2+y^2-1$. Thus $2u(y)=0,q(y)-2(y^2-1)t(y)=0$. Have $q’(y)=4yt(y)+2(y^2-1)t’(y)$
Next we have 
\begin{align}
2yp(x,y)+xq’(y)+r’(y)&=2y(x^2+y^2-1)s(x,y)+2xyt(y)+2yu(y)+xq’(y)+r’(y)\\
&=2y(x^2+y^2-1)s(x,y)+x(2yt(y)+4yt(y)+2(y^2-1)t’(y))+r’(y)\\
\end{align}
 is divisible by $x^2+y^2-1$. Thus $6yt(y)+2(y^2-1)t’(y)=0, r’(y)=0$. Thus $r(y)=c$ for some constant $c$.
We shall show $t(y)=0$. Assume on the contrary $t$ is not identically $0$. Let $t$ have degree $n$ with nonzero leading coefficient $a$. Comparing the leading coefficient in $6yt(y)+2(y^2-1)t’(y)=0$, we get $6a=2an$, so $n=3$. Note $t$ is divisible by $y^2-1$, so $t(y)=a(y^2-1)(y+b)$, some $b \in \mathbb{R}$. Substituting $y=0$ in $6yt(y)+2(y^2-1)t’(y)=0$ gives $t’(0)=0$. However $t’(0)=-a$ is nonzero, a contradiction. Thus $t(y)=0$, and so $q(y)=2(y^2-1)t(y)=0$.
Thus 
\begin{align}
f(x,y)&=(x^2+y^2-1)p(x,y)+xq(y)+r(y)\\
&=(x^2+y^2-1)^2s(x,y)+x(x^2+y^2-1)t(x,y)+(x^2+y^2-1)u(y)+xq(y)+r(y)\\
&=(x^2+y^2-1)^2s(x,y)+c\\
\end{align}
and we are done.
