QOJ.ac

QOJ

时间限制: 1 s 内存限制: 128 MB 总分: 100

#16139. Split Matrix

统计

Split an $a \times b$ numerical matrix as follows: split the original matrix along a straight line into two matrices, then continue to split the resulting matrices in the same way (it is also possible to split only one of them). After performing this split $(n-1)$ times, the original matrix is divided into $n$ matrices. (Each split can only be made along the gaps between the numbers.)

Each position in the original matrix has a value, and the total score of a matrix is the sum of the values at all positions it contains. Now, we need to divide the matrix into $n$ matrices according to the above rules such that the mean square error of the total scores of the $n$ matrices is minimized.

Write a program to find the minimum mean square error for the given matrix and $n$.

Input

The first line contains three integers $a, b, n$ ($1 < a, b \le 10, 1 < n \le 10$).

The next $a$ lines each contain $b$ non-negative integers less than $100$, representing the values at the corresponding positions in the matrix. Adjacent numbers in each line are separated by a space.

Output

A single number, which is the minimum mean square error (rounded to 2 decimal places).

Examples

Input 1

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

Output 1

0.50

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.