I have solved a programming problem with a Equation. But can't simulate this equation briefly. Anyone can help me?
Question: I have $n$ rubles initially. The cost of one plastic litre bottle, the cost of one glass litre bottle, and the money one can get back by returning an empty glass bottle are $a$, $b$ and $c$, respectively, where $1\leqslant a\leqslant10^{18}$, $1\leqslant c<b\leqslant10^{18}$. I need the maximum number of litre I can drink with my rubles.
Number of glass litre is $\dfrac{n-c}{b-c}$.
Then total litre will be:
$t1 = \dfrac{n-c}{b-c}$
${n = n -(b-c)*t1}$
$t2 = \frac{n}{a}$
$ans = t1 + t2$
How this simulation has come? Can anyone please elaborate?
Example: $n=10$ $a=11$ $b=9$ $c=8$
Answer will be $2$