#K42402. Average Speed and Cumulative Split Times Calculator
Average Speed and Cumulative Split Times Calculator
Average Speed and Cumulative Split Times Calculator
This problem requires you to implement two functionalities based on the given operation type:
- Operation 1: Compute the average speed in meters per second (m/s) using the formula $$speed = \frac{total\_kilometers \times 1000}{total\_seconds}$$. The result should be rounded to 2 decimal places.
- Operation 2: Compute the cumulative split times. You are given a list of split times (in seconds) and a corresponding list of distances (in kilometers). For each segment, output a pair consisting of the split time and the cumulative time (i.e. sum of all previous split times, including the current one), both rounded to 2 decimal places.
The input will indicate which operation to perform and provide the necessary values. Make sure your solution reads from standard input and writes to standard output.
inputFormat
The input begins with a single integer indicating the operation type:
- If the type is
1
, the next line contains two numbers:total_seconds
andtotal_kilometers
. - If the type is
2
, the next input consists of the following:- An integer
N
representing the number of segments. - A line with
N
space-separated numbers representing the split times (in seconds). - A line with
N
space-separated numbers representing the distances (in kilometers). (Note: these values are provided for completeness but are not used in calculations.)
- An integer
outputFormat
For Operation 1: Output a single floating point number representing the average speed (in m/s), rounded to 2 decimal places.
For Operation 2: Output N
lines. Each line should contain two floating point numbers: the split time and the cumulative time (both rounded to 2 decimal places), separated by a space.
1
3600 10
2.78
</p>