Derive the Cost Function TC(Q)
You are trying to find the solution of $K$ and $L$ in terms of $Q$ to derive the total cost function with respect to quantity.

Page 13 of this lecture has the exact question you are interested in. (Google is your friend.)


From the Lagrangian you'll have $\frac{K}{L}=\frac{w}{r}$
From the production constraint you'll have $50K^{\frac{1}{2}}L^{\frac{1}{2}} = 1000$ and you have already derived the solution to this.


The first implies that $4K = L$ given your solution.

Then since,
$50K^{\frac{1}{2}}L^{\frac{1}{2}} = Q$

$$\implies 50K^{\frac{1}{2}}(4K)^{\frac{1}{2}} = Q \\
\implies 100K = Q \\
\implies K(Q) = \frac{Q}{100}$$

A similar solution can be found for $L(Q)$, and then it should be smooth sailing for you from there.