for (int i = 1; i <= MAXB; i++) { for (int j = 1; j <= MAXB; j++) { s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + board[i][j]; } }
for (int l = 1; l <= MAXB; l++) { for (int d = 1; d <= MAXB; d++) { for (int r = l; r <= MAXB; r++) { for (int u = d; u <= MAXB; u++) { f[1][l][d][r][u] = pow(getTri(l, d, r, u)); } } } } }
inlinevoiddp(){ for (int i = 2; i <= n; i++) { for (int l = 1; l <= MAXB; l++) { for (int d = 1; d <= MAXB; d++) { for (int r = l; r <= MAXB; r++) { for (int u = d; u <= MAXB; u++) { for (int j = l; j < r; j++) f[i][l][d][r][u] = std::min(f[i][l][d][r][u], std::min(f[i - 1][l][d][j][u] + f[1][j + 1][d][r][u], f[1][l][d][j][u] + f[i - 1][j + 1][d][r][u])); for (int j = d; j < u; j++) f[i][l][d][r][u] = std::min(f[i][l][d][r][u], std::min(f[i - 1][l][d][r][j] + f[1][l][j + 1][r][u], f[1][l][d][r][j] + f[i - 1][l][j + 1][r][u])); } } } } } }
intmain(){ std::cin >> n; for (int i = 1; i <= MAXB; i++) { for (int j = 1; j <= MAXB; j++) { scanf("%d", &board[i][j]); } }