#C9843. Maximizing Crop Yield
Maximizing Crop Yield
Maximizing Crop Yield
You are given one or more grids representing farmland. For each grid, the first line contains three integers m, n, and d where:
- m is the number of rows in the grid.
- n is the number of columns in the grid.
- d is the number of days available for crop growth.
Each of the next m lines contains n integers representing the growth rates in that row. The input terminates with a line containing "0 0" (which signals the end of input and should not be processed).
For each grid, find the maximum cell value M in the grid. The maximum yield is then given by the formula: \[ Y = M \times d \] Output the yield for each grid on a new line.
inputFormat
The input consists of one or more datasets. Each dataset begins with a line containing three integers m, n, and d (where m and n are the dimensions of the grid and d is the number of days), followed by m lines each containing n integers. The input ends with a line containing "0 0".
outputFormat
For each dataset, output a single line containing the maximum yield calculated by multiplying the highest growth rate in the grid by the number of days d.
## sample3 3 5
4 7 3
2 9 1
5 3 8
0 0
45
</p>