#K2196. Calculate Average Cost of City Plots

    ID: 24683 Type: Default 1000ms 256MiB

Calculate Average Cost of City Plots

Calculate Average Cost of City Plots

In this problem, you are given a grid that represents the cost of plots in a city layout. You will also be provided with (x) queries, each of which specifies a subgrid by its top-left corner ((r_1, c_1)) and bottom-right corner ((r_2, c_2)). Your task is to calculate the average cost of the subgrid defined by each query. The average cost is defined as (\frac{\text{total cost}}{\text{number of cells}}) and should be printed rounded to exactly two decimal places.

Note: The rows and columns are 0-indexed.

inputFormat

The input is given from standard input (stdin) in the following format:

(n) (m) (x)
Next (n) lines: Each line contains (m) integers representing the cost grid of the city.
Next (x) lines: Each line contains 4 integers (r_1), (c_1), (r_2), and (c_2), defining a query for the subgrid.

outputFormat

For each query, output the average cost of the specified subgrid on a new line. The answer must be rounded and printed to exactly two decimal places.## sample

3 3 2
1 2 3
4 5 6
7 8 9
0 0 1 1
1 1 2 2
3.00

7.00

</p>