If the ratio of the speeds of A and B is a : b, then the ratio of the times taken by them to cover the same distance is 1/a : 1/b or b : a
Suppose a man covers a certain distance at a km/hr and an equal distance at b km/hr. Then the average speed during the whole journey is $ \left(\dfrac{2\text{ab}}{\text{a}+\text{b}}\right)$ km/hr.