数据弱,暴力过
题意
N^N的矩阵,求最大子矩阵和
思路
悬线?不需要。暴力+前缀和过
代码
//poj1050
//n^4暴力
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#define N 105
#define INF 0x3fffffff
using namespace std;
int a[N][N];
int sum[N];
int ans;
int main()
{
int n; scanf("%d", &n);
for (int i = ; i <= n; i++)
for (int j = ; j <= n; j++)
scanf("%d", &a[i][j]);
for (int i = ; i <= n; i++) {
memset(sym, , sizeof(sum));
for (int j = i; j <= n; j++) {
int num = ;
for (int k = ; k <= n; k++) {
num += sum[k] += a[j][k];
ans = max(ans, num);
if (num < ) num = ;
}
}
}
printf("%d\n", ans);
return ;
}
PS:VS编译坏了,伤心!