How can we express a number $n$ as $pa+qb$ where $p \geq0$ and $q \geq 0$ and $p$ and $q$ can't be fraction. In contest I got a puzzle as if we can express $c$ as sum of $a$ and $b$ in form $pa+qb$. Suppose $a$ is $3$ and $b$ is $4$ and $c$ is $7$ so we can express $7$ as $3+4$. Suppose $a$ is $4$ and $b$ is $6$ and $c$ is $15$ but we can't express $15$ as sum of $4 \cdot p+6 \cdot q$.
NOTE: $p$ AND $q$ CAN'T BE FRACTIONS.
I came up with an approach to take $\gcd$ of $a$ and $b$ and check if their $\gcd$ leaves zero as remainder when $\gcd$ divides $c$. Is there any general method to check this ?