Problem C
Three Blind Mice
Three blind mice, three blind mice,
See how they run, see how they run!
They all ran after the farmer’s wife,
Who cut off their tails with a carving knife,
Did you ever see such a sight in your life,
As three blind mice?
Wow! That wife certainly knew how to deal with vicious mice! So here is the picture: Three mice, presumably at the same time from their mouse hole in the wall, rush at different speeds toward the wife, apparently knowing where she was because of their sharp hearing. She races towards the mice with her carving knife grasped in her hand. As she reaches each mouse, she chops off its tail, at which point it "turns tail" and runs back at possibly even greater speed. They only stop running when they each reach their mouse hole.
Your task is to determine the total distance the mice run. We will provide you with the initial distance of the mice from the wife which is also the distance of the wife from the mouse hole, the speed of the wife and the speeds of each mouse rushing toward the wife.
Input
There will be 5 lines of input containing one integer each.
-
Initial distance between the wife and the mouse hole (0-100 feet)
-
Speed of the wife (0-20 feet per second)
-
Speed of first mouse number (1-20 feet per second)
-
Speed of second mouse number (1-20 feet per second)
-
Speed of third mouse number (1-20 feet per second)
Output
Print the sum of the distances that the 3 mice ran both toward the wife and back to the hole. Round to the nearest foot.
Sample Input 1 | Sample Output 1 |
---|---|
50 10 5 10 15 |
143 |
Sample Input 2 | Sample Output 2 |
---|---|
50 30 5 10 15 |
73 |