Question 561656
It's easier for me to think of one train
standing still and the other passing it
at 2 different speeds:
{{{ s[1] + s[2] }}} ( opposite direction speed )
{{{ s[2] - s[1] }}} ( same direction speed )
I picked {{{ s[2] }}} to be faster speed
--------------
The head of the moving train goes from the tail of the 
still train to it's head ( 400 ft )
Then the tail of the moving train has to go from the
tail of the still train to it's head ( another 400 ft )
The moving train travels {{{ 800 }}} ft passing
the still train
---------------
(1) {{{ 800 = ( s[1] + s[2] )*5 }}}
and
(2) {{{ 800 = ( s[2] - s[1] )*20 }}}
Speeds will be in ft/sec
----------------
(1) {{{ 5s(1) + 5s(2) = 800 }}}
(2) {{{ -20s[1] + 20s(2) = 800 }}}
----------------
Multiply both sides of (1) by {{{ 4 }}} and 
add the equations
(1) {{{ 20s(1) + 20s(2) = 3200 }}}
(2) {{{ -20s[1] + 20s(2) = 800 }}}
{{{ 40s[2] = 4000 }}}
{{{ s[2] = 100 }}}
substitute this into (1)
(1) {{{ 5s(1) + 5*100 = 800 }}}
(1) {{{ 5s[1] = 800 - 500 }}}
(1) {{{ 5s[1] = 300 }}}
(1) {{{ s[1] = 60 }}}
The faster train travels at 100 ft/sec
The slower train travels at 60 ft/sec
check answer:
(1) {{{ 800 = ( s[1] + s[2] )*5 }}}
(1) {{{ 800 = ( 60 + 100 )*5 }}}
(1) {{{ 800 = 160*5 }}}
(1) {{{ 800 = 800 }}}
and
(2) {{{ 800 = ( s[2] - s[1] )*20 }}}
(2) {{{ 800 = ( 100 - 60 )*20 }}}
(2) {{{ 800 = 40*20 }}}
(2) {{{ 800 = 800 }}}
OK