Equality of a quadratic function 
Let $f: \mathbb{R}\rightarrow \mathbb{R}$ an arbitrary function and $g:  \mathbb{R}\rightarrow \mathbb{R} $ a quadratic function with the following property:
For any $m$ and $n$ the equation $f(x)=mx+n$ has a solution iff the equation $g(x)=mx+n$ has a solution.
Prove that $f$ and $g$ are equal.

I proved that the range for both are equal, but no idea of proving the complete statement
 A: The following solution is a more explicit (algebraic) description of the geometric ideas from the previous solution.
Suppose $g(x)=ax^2+bx+c$, and suppose that $f \neq g$. Assume that $a>0$ (otherwise you can consider $-g$ and $-f$). Consider two cases:
Case $1$: $f(x) \geq g(x)$ for all $x \in \mathbb{R}$. Since $f \neq g$ ,there exists $x_0 \in \mathbb{R}$ such that $f(x_0)>g(x_0)$. Let $m=g'(x_0) = 2ax_0+b$, and let $n=g(x_0)-mx_0 = c-ax_0^2$. Then the equation $g(x)=mx+n$ has a solution at $x_0$. However, $f(x_0)>g(x_0)=mx_0+n$, and $f(x)-mx-n\geq g(x)-mx-n=a(x-x_0)^2>0$ for $x \neq x_0$. Therefore the equation $f(x)=mx+n$ has no solutions in $\mathbb{R}$.
Case $2$. There exists $x_0 \in \mathbb{R}$ such that $g(x_0)>f(x_0)$. In this case, let $m=g'(x_0)=2ax_0+b$ and let $n=f(x_0)-mx_0=f(x_0)-2ax_0^2-bx_0$. Then the equation $f(x)=mx+n$ has a solution at $x_0$, but $g(x)-mx-n=a(x-x_0)^2+(g(x_0)-f(x_0))$, which is never zero (since $a>0$ and $g(x_0)>f(x_0)$), so the equation $g(x)=mx+n$ has no solutions in $\mathbb{R}$.
Hence we have shown that if $f \neq g$, then there exist $m,n$ such that one of the equations $f(x)=mx+n$ or $g(x)=mx+n$ has a solution and the other does not.
A: The sketch:
WLOG let $g$ curves up.


*

*$f(x_0) \not\lt g(x_0)$. Suppose $f(x_0) < g(x_0)$. Call tangent line of $g$ at $x_0$ as $h$. Then $h-\epsilon$ does not meet $g$ at any point. (Because $g$ is quadratic) However, for a certain $\epsilon$, this line pass through $f(x_0)$. Contradiction. Since the choice of $x_0$ is arbitrary, $f \geq g$.

*$f(x_0) \not\gt g(x_0)$. From (1), $f(x) \geq g(x) > h(x) ~\forall x \neq x_0$. Suppose $f(x_0)>g(x_0)$, $h$ does not meet any point on $f$, however $h$ meet $g$ at $x_0$. Contradiction.


Therefore $f(x_0) = g(x_0)$. Since the choice of $x_0$ is arbitrary, $f=g$.
