#K50917. Plant Height Calculation

    ID: 28971 Type: Default 1000ms 256MiB

Plant Height Calculation

Plant Height Calculation

Tom is a dedicated gardener managing a special garden with n plants. Each plant grows according to its own pattern. The growth model is given by the formula: \( h = h_{0} + g \times d \), where \( h_{0} \) is the initial height, \( g \) is the daily growth rate, and \( d \) is the number of days.

Your task is to compute the height of each plant after a specified number of days for each dataset. The problem tests your ability to accurately read and process multiple test cases from standard input, perform basic arithmetic operations, and produce the correct output format.

inputFormat

The input is read from standard input (stdin). The first line contains an integer \( T \) representing the number of datasets. Following that, each dataset is given in the following format:

  1. A line with an integer \( n \) — the number of plants.
  2. Next \( n \) lines, each containing two integers \( h \) and \( g \) representing the initial height and the daily growth rate of a plant.
  3. A line with an integer \( d \) — the number of days after which the height is to be calculated.

For example, a single dataset might look like:

3
10 2
15 1
20 0
5

This corresponds to 3 plants with their respective initial heights and growth rates, and you are to compute the heights after 5 days.

outputFormat

For each dataset, output one line containing \( n \) integers separated by a space. Each integer is the height of a plant after \( d \) days, computed using the formula \( h = h_{0} + g \times d \).

For instance, for the input example above the output should be:

20 20 20
## sample
1
3
10 2
15 1
20 0
5
20 20 20

</p>