#P5752. [NOI1999] 棋盘分割
[NOI1999] 棋盘分割
Description
Partition an chessboard as follows: cut off a rectangular piece from the original board such that the remaining part is also a rectangle, then continue partitioning the remaining part in the same way. After cutting times, together with the final remaining rectangle, there are a total of rectangular pieces. (Each cut can only be made along the edges of the grid cells.)

Each cell on the original board has a score. The total score of a rectangular piece is the sum of the scores of all cells it contains. Now you need to partition the board into rectangular pieces according to the rule above, and minimize the standard deviation of the total scores of all rectangular pieces.
The standard deviation is
$$\sigma = \sqrt{ \frac{ \sum_{i=1}^n (x_i - \bar x)^2 } { n }}$$where the average is
and is the score of the -th rectangular piece.
Given the board and , compute the minimum possible value of .
Input Format
The first line contains an integer ().
Lines 2 to 9 each contain non-negative integers less than , representing the scores of the corresponding cells on the board. Adjacent numbers in each line are separated by one space.
Output Format
Output only one number, , rounded to three digits after the decimal point.
3
1 1 1 1 1 1 1 3
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 0
1 1 1 1 1 1 0 3
1.633
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号