HDU ACM 1081 To The Max->最大子矩阵】的更多相关文章

分析:利用求最大子段和的思想进行求解. 1.首先累加s[i][j].表示第j列中i从第1行加到第i行的和. 2.对每一列的i1到i2行的和进行计算(0<i1<i2<=n),得出t[k],k表示列值. 3.对t[k]求最大字段和. 4.对全部t[k]求出的最大字段和求最大值,就可以得到最大子矩阵的和. 5.注意:对maxres=0;maxres|=1<<31;的解释.二进制最高位(符号位)置1,其它全部位置0,该数能够变为最小负数,前提为有符号数. #include<io…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1081 To The Max Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8839    Accepted Submission(s): 4281 Problem Description Given a two-dimensional ar…
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 11810    Accepted Submission(s): 8362 Problem Description "Well, it seems the first problem is too easy. I will let…
 To The Max Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 10839    Accepted Submission(s): 5191 Problem Description Given a two-dimensional array of positive and negative integers, a sub-re…
To The Max Problem's Link: http://acm.hdu.edu.cn/showproblem.php?pid=1081 Mean: 求N*N数字矩阵的最大子矩阵和. analyse: 乍看题目意思很简单,但对于刚开始学DP的新手来说也不是很简单. 这道题使用到的算法是:预处理+最大连续子串和 如果会做最大连续子串和,那么理解这题就相对简单一些,若不知道最大连续子串和,建议先看一下这两题: http://acm.hdu.edu.cn/showproblem.php?pi…
HDU 1081 题意:给定二维矩阵,求数组的子矩阵的元素和最大是多少. 题解:这个相当于求最大连续子序列和的加强版,把一维变成了二维. 先看看一维怎么办的: int getsum() { ; int ans=-1e9; ;i<=n;i++){ ) tot=; tot+=a[i]; if(tot>ans) ans=tot; } return ans; } 这种做法太棒了!短短几行,就能解决最大子序列和这个问题.其实这几行代码值得深思.而且这是个在线算法,输入数据及时能给出结果,感觉不能归于动归…
To The Max Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7620    Accepted Submission(s): 3692 Problem Description Given a two-dimensional array of positive and negative integers, a sub-rectang…
点我看题目 题意 : 给你一个n*n的矩阵,让你找一个子矩阵要求和最大. 思路 : 这个题都看了好多天了,一直不会做,今天娅楠美女给讲了,要转化成一维的,也就是说每一列存的是前几列的和,也就是说 0 -2 -7 0 9 2 -6 2-4 1 -4 1-1 8 0 -2 处理后就是:0  -2  -9  -99   11  5   7-4 -3  -7  -6-1  7   7   5 #include <iostream> #include <stdio.h> #include &…
题目链接 Problem Description Given a two-dimensional array of positive and negative integers, a sub-rectangle is any contiguous sub-array of size 1 x 1 or greater located within the whole array. The sum of a rectangle is the sum of all the elements in th…
Problem Description Given a two-dimensional array of positive and negative integers, a sub-rectangle is any contiguous sub-array of size 1 x 1 or greater located within the whole array. The sum of a rectangle is the sum of all the elements in that re…