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. 一起学libcef--搭建自己的libcef运行环境(Win32程序,错误C2220解决方案)

    转自 http://blog.csdn.net/wangshubo1989/article/details/50180413 现在就来讲讲如何在自己的win32程序中搭建libcef运行环境. 首先就 ...

  2. Python学习—数据库篇之SQL语句

    一.数据库级别 1.显示数据库 show databases; 默认数据库: mysql - 用户权限相关数据 test - 用于用户测试数据 information_schema - MySQL本身 ...

  3. C#读取OPC server

    1.安装opc server https://blog.csdn.net/yhtppp/article/details/80676118 2.c#读取opc https://github.com/le ...

  4. Python学习之MacBook Pro中Python3.7安装pip以及numpy

    安装pip查看https://www.cnblogs.com/cxmo/p/10513502.html 安装numpy只需要在终端(在pycharm界面的终端下)输入:pip3.7 install n ...

  5. 【转载】Linux系统下命令行连接蓝牙设备 查看查找 蓝牙

    Linux系统下命令行连接蓝牙设备 2018年11月26日 10:47:27 Zz笑对一切 阅读数:741   1.打开系统蓝牙 sudo service bluetooth start 1 进入bl ...

  6. wpf 给listview的数据源转换为集合

    目的是点击某个按钮把一条数据从 itemssource中移除 private void delete_Click_1(object sender, RoutedEventArgs e) { DtsIn ...

  7. redis单例模式

    看到好多面试都问设计模式,我就简单的了解了一下,顺便把之前封装好的Reis做了一次修改. 单例模式(Singleton Pattern 单件模式或单元素模式) 单例模式确保某个类只有一个实例,而且自行 ...

  8. 【Thread】CountdownEvent任务并行[z]

    System.Threading.CountdownEvent  是一个同步基元,它在收到一定次数的信号之后,将会解除对其等待线程的锁定. CountdownEvent  专门用于以下情况:您必须使用 ...

  9. VSCode 常用快捷键

    快捷键 基础编辑 快捷键 作用 Ctrl+X 剪切 Ctrl+C 复制 Ctrl+Shift+K 删除当前行 Ctrl+Enter 在当前行之后插入一行 Ctrl+Shift+Enter 在当前行之前 ...

  10. 10.Redis分布式集群

    10.Redis分布式集群10.1 数据分布10.1.1 数据分布理论10.1.2 Redis数据分区10.1.3 集群功能限制10.2 搭建集群10.2.1 准备节点10.2.2 节点握手10.2. ...