hdu 1081 矩阵最大连续子序列
问题描述:二位平面图,每一个坐标都有值,正值或负值,求任意矩形中和的最大值问题
解决方案:求解图中每一个坐标为起点,求任意长度宽度的矩形的和
#include<iostream>
#include<cstdio>
using namespace std;
int in[][],d[][],maxx,n;
void ope(int bx, int by)
{
memset(d,,sizeof(d));
int i,j,k;
for(i=bx; i<=n; i++)
for(j=by; j<=n; j++)
{
d[i][j]=d[i-][j]+d[i][j-]-d[i-][j-]+in[i][j];
if( d[i][j] > maxx ) maxx=d[i][j];
} }
int main()
{ int i,j,k;
while(cin >> n)
{
for(i=; i<=n; i++)
for(j=; j<=n; j++)
cin >> in[i][j];
//for(k=1; k<=n; k++){for(int l=1; l<=n; l++)cout<<in[k][l]<<" ";cout << endl;}
maxx=-;
for(i=; i<=n; i++)
for(j=; j<=n; j++)
{
ope(i,j);
}
cout << maxx << endl;
}
return ;
}
hdu 1081 矩阵最大连续子序列的更多相关文章
- hdu 1024(最大和连续子序列增强版)
题意:最大和连续子序列的增强版,要求从一序列中取出若干段,这些段之间不能交叉,使得和最大并输出. 分析:用dp[i][j]表示前j个数取出i段得到的最大值,那么状态转移方程为dp[i][j]=max( ...
- HDU 1231:最大连续子序列(DP)
pid=1231">最大连续子序列 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Jav ...
- [POJ1050]To the Max (矩阵,最大连续子序列和)
数据弱,暴力过 题意 N^N的矩阵,求最大子矩阵和 思路 悬线?不需要.暴力+前缀和过 代码 //poj1050 //n^4暴力 #include<algorithm> #include& ...
- HDU 1081 To the Max 最大子矩阵(动态规划求最大连续子序列和)
Description Given a two-dimensional array of positive and negative integers, a sub-rectangle is any ...
- DP专题训练之HDU 1231 最大连续子序列
Description 给定K个整数的序列{ N1, N2, ..., NK },其任意连续子序列可表示为{ Ni, Ni+1, ..., Nj },其中 1 <= i <= j < ...
- HDU 1231 最大连续子序列 &&HDU 1003Max Sum (区间dp问题)
C - 最大连续子序列 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit ...
- HDU 1231 最大连续子序列 --- 入门DP
HDU 1231 题目大意以及解题思路见: HDU 1003题解,此题和HDU 1003只是记录的信息不同,处理完全相同. /* HDU 1231 最大连续子序列 --- 入门DP */ #inclu ...
- HDU 1231 最大连续子序列:水dp
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1231 题意: 给你一个整数序列,求连续子序列元素之和最大,并输出该序列的首尾元素(若不唯一,输出首坐标 ...
- 最大连续子序列 -- hdu -- 1231
http://acm.hdu.edu.cn/showproblem.php?pid=1231 最大连续子序列 Time Limit: 2000/1000 MS (Java/Others) Mem ...
随机推荐
- struts2 标签的使用之一 s:if(遍历中s:if如何用等)
http://blog.csdn.net/chinajust/article/details/3922718
- Nhibernate总结(一)查询返回指定字段
项目查询中,常常需要返回指定的字段,下面是三种Nhibernate的方法1.linq to Nhibernatepublic class NameID{ public int Id { get; se ...
- MySQL常见问题汇总(原创)
本文记录了使用Mysql时遇到的问题,持续更新中... 1.在windows命令行下登录mysql时报错: C:\Program Files\MySQL\MySQL Server 5.0\bin> ...
- iOS 此证书的签发者无效
1.先检查Apple Worldwide Developer Relations Certification Authority Intermediate Certificate证书是否过期,该证书过 ...
- iOS Core Animation学习总结(1)--CALayer常用属性
图层是core animation的基础, UIView之所以能显示在屏幕上,靠的是其内部的这个图层,即每个UIView 都有 CALayer,可通过UIView.layer或者[UIView lay ...
- C++ 虚函数与纯虚函数
#include<iostream> #include<string> using namespace std; class A{ public: virtual void f ...
- SGU Volume 1
SGU 解题报告(持续更新中...Ctrl+A可看题目类型): SGU101.Domino(多米诺骨牌)------------★★★type:图 SGU102.Coprimes(互质的数) SGU1 ...
- Introduction to object
1 Declarations VS definitions (Page 81) declarations: This function or variable exists somew ...
- 原生js实现吸顶导航和回到顶部特效
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Coursera《machine learning》--(14)数据降维
本笔记为Coursera在线课程<Machine Learning>中的数据降维章节的笔记. 十四.降维 (Dimensionality Reduction) 14.1 动机一:数据压缩 ...