http://poj.org/problem?id=1050 我们已经知道求最大子段和的dp算法 参考here  也可参考编程之美有关最大子矩阵和部分. 然后将这个扩大到二维就是这道题.顺便说一下,有时候不要把问题想复杂了,有些问题只能靠暴力求解,而这道题是暴力加算法. 在这个题中,我们可以把二维压缩到一维然后求解最大子段.我们先枚举所求矩阵的起点行和结束行,然后把每一列的数据之和求出,用这些数据和就构造出一个一维的数组(代码中我没有明确表示出这个数组),然后用最大子段和的dp算法求解. 关于二…
To the Max Time Limit: 1000MSMemory Limit: 10000K Total Submissions: 38573Accepted: 20350 Description Given a two-dimensional array of positive and negative integers, a sub-rectangle is any contiguous sub-array of size 1*1 or greater located within t…
To the Max   Description Given a two-dimensional array of positive and negative integers, a sub-rectangle is any contiguous sub-array of size 1*1 or greater located within the whole array. The sum of a rectangle is the sum of all the elements in that…
传送门: http://poj.org/problem?id=1050 To the Max Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 52306   Accepted: 27646 Description Given a two-dimensional array of positive and negative integers, a sub-rectangle is any contiguous sub-arr…
题目链接 题意:给定N*N的矩阵,求该矩阵中和最大的子矩阵的和. 题解:把二维转化成一维,算下就好了. #include <cstdio> #include <cstring> #include <algorithm> using namespace std; typedef long long ll; ; ll ans=-,tmp,data[N][N],a[N]; ,ansj1=,ansi2=,ansj2=,tmp1=,tmp2=,n,m; int main() {…
转载请注明出处:http://blog.csdn.net/u012860063 Description Given a two-dimensional array of positive and negative integers, a sub-rectangle is any contiguous sub-array of size 1*1 or greater located within the whole array. The sum of a rectangle is the sum…
Description Given a two-dimensional array of positive and negative integers, a sub-rectangle is any contiguous sub-array of size 1*1 or greater located within the whole array. The sum of a rectangle is the sum of all the elements in that rectangle. I…
http://poj.org/problem?id=1050 设sum[i][j]为从(1,1)到(i,j)的矩形中所有数字之和 首先处理出sum[i][j],此时左上角为(x1,y1),右下角为(x2,y2)的矩形中所有数字之和就是sum[x2][y2]-sum[x1][y2]-sum[x2][y1]+sum[x1][y1] 因为n<100,在不需要优化的边上,所以就直接暴力了 #include <cstdio> #include <cstring> #include &l…
题目地址:http://poj.org/problem?id=1050 Description Given a two-dimensional array of positive and negative integers, a sub-rectangle is any contiguous sub-array of size 1*1 or greater located within the whole array. The sum of a rectangle is the sum of a…
题意:一个N * N的矩阵,求子矩阵的最大和(N <= 100, -127 <= 矩阵元素 <= 127). 题目链接:http://poj.org/problem?id=1050 -->>将二维压缩为一维.对一维进行dp求解. 将二维压缩成一维: 1.第1行 2.第2行加第1行 3.第3行加第2行加第1行 -- N.第N行加第N-1行加--加第1行 1.第2行 2.第3行加第2行 -- 1.第N行 对于一维情况.设dp[i]表示以第i个元素结尾的最大连续和,则状态转移方程为…