a11   a12   a13   a14   a15

a21   a22   a23   a24   a25

a31   a32   a33   a34   a35

a41   a42   a43   a44   a45

a51   a52   a53   a54   a55

枚举矩阵每一列的区间,当成最长子串的dp方式就能过了

你把a21  a31  a41 看成一个元素,值是这三个元素的和,后面的列同理

https://www.cnblogs.com/GodA/p/5237061.html

这个人讲的非常好

#include<iostream>
#include <cstdio>
using namespace std;
const int maxn = ;
int arr[maxn][maxn];
int sum[maxn][maxn];
int main()
{
int n;
scanf("%d",&n);
for(int i = ; i <= n; ++i )
{
for(int j = ; j <= n; ++j)
{
scanf("%d",&arr[i][j]);
}
}
for(int i = ; i <= n; ++i)
{
for(int j = ; j <= n; ++j)
{
sum[i][j] = sum[i][j-] + arr[j][i];
}
}
/*for(int i = 1; i <= n; ++i)
{
for(int j = 1; j <= n; ++j)
{
printf("%d\n",sum[i][j]);
}
}*/
int maix = ;
for(int i = ; i <= n; ++i)
{
for(int j = i+; j <= n; ++j)
{
int b = ;
for(int k = ; k <= n; ++k )
{
if(b > )
{
b += sum[k][j] - sum[k][i];
}
else
{
b = sum[k][j] - sum[k][i];
}
if(b > maix)
maix = b;
}
}
}
printf("%d\n",maix);
}

poj 1050 最大子矩阵的更多相关文章

  1. poj 1050 To the Max(最大子矩阵之和)

    http://poj.org/problem?id=1050 我们已经知道求最大子段和的dp算法 参考here  也可参考编程之美有关最大子矩阵和部分. 然后将这个扩大到二维就是这道题.顺便说一下,有 ...

  2. POJ 1050 To the Max 最大子矩阵和(二维的最大字段和)

    传送门: http://poj.org/problem?id=1050 To the Max Time Limit: 1000MS   Memory Limit: 10000K Total Submi ...

  3. [ACM_动态规划] POJ 1050 To the Max ( 动态规划 二维 最大连续和 最大子矩阵)

    Description Given a two-dimensional array of positive and negative integers, a sub-rectangle is any ...

  4. poj 1050 To the Max(最大子矩阵之和,基础DP题)

    To the Max Time Limit: 1000MSMemory Limit: 10000K Total Submissions: 38573Accepted: 20350 Descriptio ...

  5. poj 1050 To the Max_dp求最大子矩阵和

    题意:求最大子矩阵和 利用dp[i]每次向下更新,构成竖起的单条矩阵,再按不小于零就加起来来更新,构成更大的矩阵 #include <iostream> #include<cstdi ...

  6. POJ 1050 To the Max (最大子矩阵和)

    题目链接 题意:给定N*N的矩阵,求该矩阵中和最大的子矩阵的和. 题解:把二维转化成一维,算下就好了. #include <cstdio> #include <cstring> ...

  7. hdu 1081 &amp; poj 1050 To The Max(最大和的子矩阵)

    转载请注明出处:http://blog.csdn.net/u012860063 Description Given a two-dimensional array of positive and ne ...

  8. poj 1050 To the Max 最大子矩阵和 经典dp

    To the Max   Description Given a two-dimensional array of positive and negative integers, a sub-rect ...

  9. (POJ - 1050)To the Max 最大连续子矩阵和

    Given a two-dimensional array of positive and negative integers, a sub-rectangle is any contiguous s ...

随机推荐

  1. hibernate多生成一个外键以及映射文件中含有<list-index>标签

    (原文地址: http://blog.csdn.net/xiaoxian8023/article/details/15380529) 一.Inverse是hibernate双向关系中的基本概念.inv ...

  2. Centos 7下网卡bonding配置之mode4

    一.bonding技术 bonding(绑定)是一种linux系统下的网卡绑定技术,可以把服务器上n个物理网卡在系统内部抽象(绑定)成一个逻辑上的网卡,能够提升网络吞吐量.实现网络冗余.负载等功能,有 ...

  3. Error merging: refusing to merge unrelated histories

    解决方案: git pull git pull origin master git pull origin master --allow-unrelated-histories idea提交git提交 ...

  4. C++ 深入理解 虚继承、多重继承和直接继承

    [摘要] 本文从5段代码实例出发,通过类中类的普通继承,类的虚继承,类的多重继承,多个虚函数类的普通继承.虚继承与多重继承,几个交叉概念,详细的阐释了继承.虚函数与虚继承的基本概念,深入剖析了继承于虚 ...

  5. CentOS7+CDH5.14.0安装全流程记录,图文详解全程实测-5安装JDK及安装mysql数据库

    1.安装JDK 可以不用卸载自带的openjdk,配好环境变量即可. 下载文件:jdk-8u151-linux-x64.tar.gz 附:JDK各版本下载地址:https://www.oracle.c ...

  6. 【noip模拟赛5】细菌 状压dp

    [noip模拟赛5]细菌   描述 近期,农场出现了D(1<=D<=15)种细菌.John要从他的 N(1<=N<=1,000)头奶牛中尽可能多地选些产奶.但是如果选中的奶牛携 ...

  7. windows下的mongodb安装与配置

    一.下载mongodb安装文件 https://www.mongodb.com/download-center/community 选择zip压缩包方式,如:mongodb-win32-x86_64- ...

  8. 7B - 今年暑假不AC

    “今年暑假不AC?” “是的.” “那你干什么呢?” “看世界杯呀,笨蛋!” “@#$%^&*%...” 确实如此,世界杯来了,球迷的节日也来了,估计很多ACMer也会抛开电脑,奔向电视了.  ...

  9. 基于IDEA工具 lombok 的使用

    一.简介 Lombok 是一种 Java™ 实用工具,可用来帮助开发人员消除 Java 的冗长,尤其是对于简单的 Java 对象(POJO).它通过注解实现这一目的. 二.lombok的添加和常用注解 ...

  10. docker镜像运行错误排查

    docker做服务时,如果客户端无法连接,错误排查: 1.先使用 docker ps 查看镜像是否都在运行中,如果没有就进入镜像查看日志 2.如果确定代码及配置文件没有问题,就需要检查镜像的替换是否正 ...