So you know that the trains are moving in opposite direction and so the distance between the two trains will be the sum of the distances each train traveled.
Let's set the speed of train A = x.
Now you know that the speed of train B is 5mph faster than that of A of set the speed of train B = x+5.
They both traveled 5 hours and are 525 miles apart, meaning that the sum of the distances each train traveled is 525 mi.
The formula that relates distance, speed, and time is:
Distance = speed * time
Knowing this, let us calculate the distances each train traveled and add them together to get 525 miles.
Train A: distance train A traveled = 5 hours * x = 5x
Train B: distance train B traveled = 5 hours * (x+5) = 5x+25
Then you know that the sum of the two distances is 525 so:
5x + 5x+25 = 525
Add the x values and move the numerical values to the right hand side of the equation (subtract 25 from both sides of the equation) to get:
10x = 500
Divide by 10 on both sides of the equation to get:
x=50 mph
So if x = 50 mph and x is the speed of train A, then the speed of train B is 5+50 = 55 mph
Speed of train A = 50 mph
Speed of train B = 55 mph
Note: You can check your answer by plugging those numbers into an equation of the sum of the distances:
distance of train A + distance of train B = 50 mph (5 hours) + 55 mph (5 hours) = 250 mi + 275mi = 525mi.
You got 525 mi. which is the number that was given in the problem!