#P2217. [HAOI2007] 分割矩阵

    ID: 1191 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>搜索2007河南各省省选记忆化搜索

[HAOI2007] 分割矩阵

Description

Partition an a×ba \times b numeric matrix as follows: cut the original matrix along a straight line into two matrices, then continue partitioning the resulting matrices in the same way (you may also choose to partition only one of them). After (n1)(n - 1) cuts, the original matrix is partitioned into nn matrices. Each cut may only be made along the gaps between numbers (i.e., along the grid lines between cells).

Each position in the original matrix has a score. The total score of a matrix is the sum of the scores at all positions it contains. Now, you need to partition the matrix into nn matrices according to the above rule, minimizing the mean square deviation of the total scores of the matrices.

Given the matrix and nn, write a program to compute the minimal value of the mean square deviation.

Input Format

The first line contains 3 integers, the values of a,b,na, b, n (1<a,b,n10)(1 < a, b, n \le 10).

From the second line to the (a+1)(a + 1)-th line, each line contains bb non-negative integers less than 100100, representing the score at the corresponding position in the matrix. Adjacent numbers in each row are separated by a single space.

Output Format

Output a single number: the minimal mean square deviation, rounded to two decimal places.

5 4 4
2 3 4 6
5 7 5 1
10 4 0 5
2 0 2 3
4 1 1 1

0.50

Hint

Translated by ChatGPT 5