标签:div int ++ string size 大学 space names main
#include <iostream> #include <cstring> #define maxn 5 + 2 using namespace std; int m, n, G[maxn][maxn], dp[maxn][maxn][maxn][maxn]; int main() { while (cin >> m >> n && m && n) { memset(G, 0, sizeof(G)); memset(dp, 0, sizeof(dp)); for (int i = 1; i <= m; ++i) for (int j = 1; j <= n; ++j) cin >> G[i][j]; for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) for (int k = 1; k <= n; ++k) { int l = i + j - k; if (l >= 1) dp[i][j][k][l] = G[i][j] + G[k][l] + max(max(dp[i - 1][j][k - 1][l], dp[i - 1][j][k][l - 1]), max(dp[i][j - 1][k - 1][l], dp[i][j - 1][k][l - 1])); else continue; if(i == k && j == l) dp[i][j][k][l] -= G[i][j]; } cout << dp[n][m][n][m] << endl; } return 0; }
标签:div int ++ string size 大学 space names main
原文地址:https://www.cnblogs.com/zousantuier/p/9825167.html