solve for s : s = c + min(s,t) * f + max(s-t,0) * g