#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#define maxn 17
#define N 8
using
namespace std;
const
int inf =
99999999;
int dp[maxn][
9][
9][
9][
9];
int map[
9][
9];
/*
int getDP(int k,int x1,int y1,int x2,int y2)
{
int mid;
int ans = inf;
for (mid = x1 + 1; mid < x2; ++mid)
{
ans = min(ans,dp[k - 1][x1][y1][mid][y2] + dp[1][mid][y1][x2][y2]);
ans = min(ans,dp[k - 1][mid][y1][x2][y2] + dp[1][x1][y1][mid][y2]);
}
for (mid = y1 + 1; mid < y2; ++mid)
{
ans = min(ans,dp[k - 1][x1][y1][x2][mid] + dp[1][x1][mid][x2][y2]);
ans = min(ans,dp[k - 1][x1][mid][x2][y2] + dp[1][x1][y1][x2][mid]);
}
return ans;
}
*/
int getS(
int x1,
int y1,
int x2,
int y2)
{
return map[x2][y2] - map[x1][y2] - map[x2][y1] + map[x1][y1];
}
int DP(
int k,
int x1,
int y1,
int x2,
int y2)
{
int mid;
if (dp[k][x1][y1][x2][y2] !=
0)
return dp[k][x1][y1][x2][y2];
//
记忆的由来
if (k ==
1)
//
分割到最小取得值
{
int tp = getS(x1,y1,x2,y2);
dp[
1][x1][y1][x2][y2] = tp*tp;
return tp*tp;
}
int ans = inf;
//
横向切割
for (mid = x1 +
1; mid < x2; ++mid)
{
ans = min(ans,DP(k -
1,x1,y1,mid,y2) + DP(
1,mid,y1,x2,y2));
ans = min(ans,DP(k -
1,mid,y1,x2,y2) + DP(
1,x1,y1,mid,y2));
}
//
纵向切割
for (mid = y1 +
1; mid < y2; ++mid)
{
ans = min(ans,DP(k -
1,x1,y1,x2,mid) + DP(
1,x1,mid,x2,y2));
ans = min(ans,DP(k -
1,x1,mid,x2,y2) + DP(
1,x1,y1,x2,mid));
}
dp[k][x1][y1][x2][y2] = ans;
return ans;
}
int main()
{
//
freopen("d.txt","r",stdin);
int n,i,j;
scanf(
"
%d
",&n);
memset(map,
0,
sizeof(map));
int sum =
0;
//
map存每个矩形的和
for (i =
1; i <= N; ++i)
for (j =
1; j <= N; ++j)
{
scanf(
"
%d
",&map[i][j]);
sum += map[i][j];
map[i][j] += map[i][j -
1] + map[i -
1][j] - map[i -
1][j -
1];
}
memset(dp,
0,
sizeof(dp));
int tmp = DP(n,
0,
0,
8,
8);
double ans = (
1.0*tmp)/n - (sum*sum*
1.0)/(n*n*
1.0);
printf(
"
%.3lf\n
",sqrt(ans));
return
0;