#C1703. Bounce Simulation
Bounce Simulation
Bounce Simulation
A ball is dropped from an initial height and bounces repeatedly, each bounce reaching a fraction (p) of the previous height. The simulation stops when the ball's bounce height becomes less than or equal to a given threshold (T). Formally, if the initial height is (H_0), then after each bounce the height is updated as (H_{i} = p \times H_{i-1}) until (H_{i} \leq T). Your task is to compute the total number of bounces (i.e. the maximum (i)) before the ball's height falls to or below (T).
If any of the input parameters are invalid (i.e. if the initial height or threshold is non-positive, or if (p) is not strictly between 0 and 1), the output should be 0.
inputFormat
The input is provided via standard input (stdin) as a single line containing three values separated by spaces:
1. An integer or float (initialHeight) representing the initial height from which the ball is dropped.
2. A float (bouncePercentage) representing the fraction of the height reached after each bounce (must satisfy (0 < bouncePercentage < 1)).
3. An integer or float (bounceThreshold) representing the threshold height at which the simulation terminates.
Note: If any parameter is invalid (i.e. non-positive, or if (bouncePercentage) is not in the interval (0,1)), the program should output 0.
outputFormat
Print to standard output (stdout) a single integer representing the total number of bounces before the ball's height becomes less than or equal to the bounce threshold.## sample
100 0.6 10
5