Accenture OA-2 2024
Problem Description
Daniel has a ball. He wants to find the ball's rebound height , which he dropped from height H with an initial velocity V. After the Nth rebound the final velocity of the ball is Vn . Your task is to help him and return an integer value representing the height to which the ball rebounds after N bounces.
Note:
- H'=H×e^2n, where H' is the rebound height, H is the initial height, e is the coefficient of restitution, and n is the number of bounces.
- e^n = V/Vn , where V is the initial velocity and Vn is the final velocity.
Input Format:
- First line contains an integer H, representing initial height
- Second line contains an integer V, representing initial velocity
- Third line contains an integer Vn, representing final velocity
Output Format:
Return an integer value representing the height to which the ball rebounds after N bounces.
Constraints
- H > 0
- V > 0
- 0 < Vn <= V
- Rebound Height > 0
Examples
Sample Input:
10
20
5
Sample Output:
160
Explanation:
In the example, the ball is dropped from a height H = 10 with an initial velocity V = 20. After N = 5 bounces, each bounce reduces the velocity due to energy loss (based on a coefficient of restitution e). The rebound height after these bounces can be calculated by finding the final velocity Vn after 5 bounces and then using it to determine the rebound height.