Solution:
Consider distinct points $p_1, p_2 \in X$. We want to show there exists neighborhoods $U_1 \subset X$ and $U_2 \subset X$ for $p_1$ and $p_2$, respectively, such that $U_1 \cap U_2 = \varnothing$.
Consider the continuous function $f$ such that $f^{-1}(\{0\})=\{p_1\}$, which exists by hypothesis. Then $f(p_1)=0$ and $f(p_2) =r\ne 0$. Since $\mathbb R$ is Hausdorff, there exists disjoint open neighborhoods $V_1$ for $0$ and $V_2$ for $r$ such that $V_1 \cap V_2 =\varnothing$. Now, $p_1 \in f^{-1}(V_1)$, $\ p_2 \in f^{-1}(V_2)$ and since $f$ is continuous $f^{-1}(V_1)$ and $f^{-1}(V_2)$ are open in $X$. Furthermore,
$$f^{-1}(V_1)\cap f^{-1}(V_2) = f^{-1}(V_1\cap V_2)=f^{-1}(\varnothing)=\varnothing.$$
So, $f^{-1}(V_1)$ and $f^{-1}(V_2)$ are disjoint open neighborhoods of $p_1$ and $p_2$. Thus, $X$ is Hausdorff.