#C9759. Race Car Distance Calculation

    ID: 53887 Type: Default 1000ms 256MiB

Race Car Distance Calculation

Race Car Distance Calculation

A car accelerates uniformly from rest to its maximum speed v (in m/s) over a period of a seconds, then maintains this speed for 1 second, and finally decelerates uniformly to a stop over a period of d seconds. The total distance traveled by the car can be computed as:

$$\text{distance} = 0.5 \times v \times a + v + 0.5 \times v \times d $$

Your task is to write a program that reads multiple test cases from standard input, computes the total distance for each case using the formula above, and prints the result for each test case on a separate line. Note that the computed distance is always an integer given the constraints.

inputFormat

The first line of input contains an integer T, the number of test cases. Each of the next T lines contains three integers: v, a, and d, separated by spaces, where:

  • v is the maximum speed of the car in m/s,
  • a is the number of seconds over which the car accelerates uniformly, and
  • d is the number of seconds over which the car decelerates uniformly.

outputFormat

For each test case, output the total distance traveled by the car as an integer on a new line.## sample

3
10 2 3
5 1 1
20 4 4
35

10 100

</p>