The distance, z, between the two cars is the length of the hypotenuse of the right triangle with vertices at the 2 cars and the intersection, with the right angle at the intersection.
Let x be car B's distance from the intersection, y be car A's distance from the intersection. We have x = 30 and dx/dt = - 45. Also, y = 40 and dy/dt = 55. Lastly, z = 50 (by pythag thm) and x2 + y2 = z2.
Differentiating with respect to t, gives 2x·dx/dt + 2y·dy/dt = 2z·dz/dt.
-2,700 + 4,400 = 100·dz/dt
dz/dt = 17 mph