For example, given $a=3$, $b=3$, and $n=14$, no such $a',b'$ exists. On the other hand, for $a=3$, $b=3$, and $n=12$, we can use $a'=3$ and $b'=4$.

Is there a simple formula that can help determine the answer to this question, rather than simply searching through possible combinations of $a'$ and $b'$?