Problem E
Jack and Jill
Jack and Jill went up the hill
To fetch a pail of water.
Jack fell down and broke his crown,
And Jill came tumbling after.Up Jack got and home did trot,
As fast as he could caper.
He went to bed to mend his head
With vinegar and brown paper.Jill came in and she did grin,
To see Jack’s paper plaster.
Mother vexed did whip her next
For causing Jack’s disaster.
Tumbling down a hill can be a bit risky. How risky may depend on whether the tumbling is rolling on one’s side like a log or somersaulting head over heels. Regardless, this problem is concerned with a possible combination of side rolls and somersaulting. Given a hill of a certain length, and the effective circumferences of the tumbler, your task is to compute the combined number of rolls of each variety that most closely results in an integral number of rolls taken to reach the bottom of the hill. In case there is more than one combination that is equally close, choose the one that maximizes the number of log-like rolls.
For example, let’s say the hill is 100.0 m, the log roll circumference is 1.0 m, and the frontal roll is 2.5 m. Each roll circumference divides evenly into 100, so we have a tie of 100 and 0 or equivalently 0 and 40. Therefore choose the log roll which yields 100 and 0 for the solution. However, if the roll circumference is 0.9 m, then 10 log rolls is 90 m and adding 4 frontal rolls adds to exactly 100.0 m and the disambiguated optimal solution is 10 and 4.
Input
The single line of input will contain 3 numbers. The first is a non-negative real number of no more than 200.0 representing the length of the hill in meters. The next two numbers are positive reals representing the circumferences of a log-like roll and a head-first roll respectively, also in meters and no more than 3.0 m. All measurements are to the nearest 0.1 m.
Output
Print two non-negative whole numbers representing the number of log-rolls and head-first rolls that combined result in the closest distance but not more than the distance to the bottom of the hill. Break ties by choosing the solution with the maximum number of log-rolls.
| Sample Input 1 | Sample Output 1 |
|---|---|
100.0 1.0 2.5 |
100 0 |
| Sample Input 2 | Sample Output 2 |
|---|---|
100.0 0.9 2.5 |
100 4 |
