Question: Assume X and Y are standing n km apart (n has to be taken as input from user). They start walking towards each other, X"s speed : m km ph and Y"s speed : p km ph ( m and p has to be taken as input from user and always k >m and k >n).
One has a parrot and other has a dove. Both birds fly with same speed say k kmph.
As soon as X and Y start walking, their birds also start flying. Once birds meet each other, they chnage their direction and start flying towards their respective owners and when they meet their owner they again change their direction and this contnues until X and Y meet. Compute total distance covered by both the birds together.
X and Y walk towards each other with a relative speed of r = m+p km/hr.
Time for their stroll is T = n/r = n/(m+p) hr.
Distance travelled by X's bird is SX = kT km.
Distance travelled by Y's bird is SY = kT km.
Total distance covered by both birds is S = SX + SY
S = kT + kT = 2kT = 2kn/(m+p) km
The formula for distance travelled is: S = 2kn/(m+p) km