Think about polynomial long division in much the same way that you think about division of real numbers.
For instance, say you want to divide 48820 by 28. In a sense, doing division in this way is "greedy" -- you divide by the largest possible parts first, then work down from there.
Now, , when you long divide by 28, you first see if 28 goes into the leading term, 4. It does not, so then you check if it goes into 48 (which it does exactly once). Then, when you "bring down" the next term, you multiply the "partial quotient" -- 1 -- by 28. Right?
Now think of 28 as 2*10+8. Same operations hold.
Now, replace 10 with x. In order to keep the algorithm the same, you have to multiply by the whole denominator.
Edit: To expand a little...
Consider the previous example. 48820/28 = 1743+16/28.
Now, let's compute $\frac{4x^4+8x^3+8x^2+2x+0}{2x+8}$.
By doing polynomial long division, we obtain: $2x^3-4x^2+20x-79+\frac{632}{2x+8}$. Now you might say, "wait a minute, that has a leading coefficient of 2, but obviously 28 goes into 48 only once!" Yes, this is true, but notice that we have minus signs here. That is key.
Now, let's set $x = 10$ and see what we compute: $2000-400+200-79+\frac{632}{28}$. Doing the arithmetic, we see this is exactly our desired result.
Best Answer
Rewriting $$ \frac{3x^3-5x^2+4x+2}{3x+1}=\frac{3x^3-5x^2+4x+2}{3\left(x+\frac{1}{3}\right)} $$ you see that you have to divide your result, obtained not taking into account the facotor $3$, by $3$.