We can write the law of motion for both trains, calling them train A and train B. Since they both move by uniform motion, so with constant velocity, we can write their position at time t as:
[tex]x_A(t) = v_A t = (80 km/h) t[/tex]
[tex]x_B(t)= v_B t = (-70 km/h) t[/tex]
where [tex]v_A[/tex] and [tex]v_B[/tex] are the average speeds of the two trains. For the train B, we put a negative sign, since it is going in the opposite direction.
We want to know the time t after which the distance between the two trains is 50 km. In equations, this means finding the time t after which
[tex]x_A (t) = 50 km + x_B(t)[/tex]
And solving, we find:
[tex](80 km/h) t = 50 km + (-70 km/h) t[/tex]
[tex]t= \frac{50 km}{80 km/h+70 km/h} =0.33 h[/tex]
Which means after 20 minutes.