HDU 1081 To The Max - 最大字段和】的更多相关文章

传送门 题目大意: 求一个矩阵的最大子矩阵和. 题目分析: 刚开始考虑了一下dp方程的递推,但是不好转.简便的方法是预处理sum[i][j]表示第i行的前j个元素之和,之后\(n^3\)枚举子矩阵就可以了. code #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<string> #include<algorithm> #…
题目链接: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…
HDU 1081 题意:给定二维矩阵,求数组的子矩阵的元素和最大是多少. 题解:这个相当于求最大连续子序列和的加强版,把一维变成了二维. 先看看一维怎么办的: int getsum() { ; int ans=-1e9; ;i<=n;i++){ ) tot=; tot+=a[i]; if(tot>ans) ans=tot; } return ans; } 这种做法太棒了!短短几行,就能解决最大子序列和这个问题.其实这几行代码值得深思.而且这是个在线算法,输入数据及时能给出结果,感觉不能归于动归…
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…
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…
 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…
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…
题目链接 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…