The $N$-th partial sum is
$$
S_N = a \sum_{k=0}^N q^k = \left\{
\begin{align}
a\frac{q^{N+1} - 1}{q - 1}, \quad q \ne 1 \\
a (N + 1), \quad q = 1
\end{align}\right.
$$
So given a problem instance $(a, S, N)$ the first step is to treat the case $a = 0$ which implies $S=0$. In this case any number will work as value for $q$. For the following we assume $a \ne 0$.
If $a \ne 0$ and $S = 0$ there is no solution $q$. For the following we assume $S \ne 0$ as well.
Next thing would be to check if
$$
S = a (N+1)
$$
in this case $q=1$ is the solution. For the following we assume $q \ne 1$ too, having $a \ne 0$, $S \ne 0$, $q \ne 1$ as constraints.
If we still got the case $S = a$, then this would require $q = q^{N + 1}$, which would have $q = 0$ as solution and additionally $q = -1$ in case of odd $N$.
Looking for Fixed Points
One method would be to search for a fixed point $q^{*}$ for
$$
f(q) = \frac{a}{S} q^{N+1} + 1 - \frac{a}{S}
$$
which fullfills $f(q^{*}) = q^{*}$.
This version of the original problem is easier to reason with, because one can treat this as the geometric problem of the graph of $f(q) = u \, q^n + v$ (two cases for even and odd exponents $n$, two cases for positive or negative factor $u$) crossing the diagonal line $\mbox{id}(q) = q$.
For odd $N$ the exponent in $f$ is even, we got some parabolic graph which has zero, one or two crossings with $\mbox{id}$ and thus that many solutions.
For even $N$ the exponent is $f$ is odd and for $N \ge 2$ there might be even a third solution.
$$a^2+4ad+4d^2=a^2+6ad+5d^2$$
$$2ad+d^2=0$$
$$d(2a+d)=0$$
$$d=0 \vee 2a+d=0$$
If $d$ is zero, then the ratio is clearly 1.
If $2a+d=0$ is zero, you have $d=-2a$. Substitute this in the first ratio we get $r=\frac{-3a}{-a}=3$.
Best Answer
Hint: Let $p,q,r$ be the terms. Let $x$ be the ratio in the geometric progression, $y$ be the increment in the arithmetic progression. $x=\frac qp, y=q-p$ Then the terms are $p, px, px^2$ and also $p, p+y, p+2y$. Can find two equations for $x$ and $y$?
Added: You have $p+y=px, p+2y=px^2$. We have two equations in two unknowns if we regard $p$ as a parameter. Subtracting, $y=px^2-px$. Dividing, $x=\frac rq=\frac {p+2y}{p+y}$. I suspect the desired answer is the solution for $x$ of these two.