#B2076. Ball Bounce Calculation
Ball Bounce Calculation
Ball Bounce Calculation
A ball is dropped from a certain height H (an integer in meters). Each time the ball hits the ground, it rebounds to half of its previous height and then falls again. Write a program to calculate:
- The total distance traveled by the ball by the time it touches the ground for the 10th time.
- The height of the rebound after the 10th impact.
Note: The initial drop counts as the first ground contact. Hence, after the first drop, the ball rebounds to \(\frac{H}{2}\) and then falls \(\frac{H}{2}\) again, and so on.
The formulas are as follows:
Total distance \(D = H + 2\left(\frac{H}{2} + \frac{H}{2^2} + \cdots + \frac{H}{2^9}\right)\) and the rebound height after the 10th impact is \(R = \frac{H}{2^{10}}\).
inputFormat
The input consists of a single integer H (in meters), the initial height from which the ball is dropped.
outputFormat
Output two floating point numbers separated by a space: the total distance traveled by the ball by the time it touches the ground for the 10th time, and the rebound height after the 10th impact. The result should be precise up to at least 6 decimal places.
sample
100
299.609375 0.097656