Junior — Senior
Calculation of the path traveled by the sparrow
livecode
Task condition
Given the distance between points A and B, the speed of the train moving from A to B, and the speed of the sparrow flying faster than the train, while the train has not yet reached point B, the sparrow makes flights from point B to meet the train and back to point B. Write a program that calculates the total distance traveled by the sparrow in kilometers.
Input data
distAB– the distance between points A and B (km);vTrain– the speed of the train (km/h);vSparrow– the speed of the sparrow (km/h), withvSparrow > vTrain.
Output data
- A single number – the total distance traveled by the sparrow, rounded to 2 decimal places.
Example
Input: 100 20 30
Output: 150.00