POJ 1050 To the Max 暴力,基础知识 难度:0
http://poj.org/problem?id=1050
设sum[i][j]为从(1,1)到(i,j)的矩形中所有数字之和
首先处理出sum[i][j],此时左上角为(x1,y1),右下角为(x2,y2)的矩形中所有数字之和就是sum[x2][y2]-sum[x1][y2]-sum[x2][y1]+sum[x1][y1]
因为n<100,在不需要优化的边上,所以就直接暴力了
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=1e2+;
double e[maxn];
int match[maxn];
int n,m;
int sum[maxn][maxn],maz[maxn][maxn];
int main()
{
scanf("%d",&n);
for(int i=; i<=n; i++)
{
for(int j=; j<=n; j++)
{
scanf("%d",maz[i]+j);
sum[i][j]=sum[i][j-]+sum[i-][j]-sum[i-][j-]+maz[i][j];
}
}
int ans=-0x7fffffff;
for(int x1=;x1<=n;x1++){
for(int y1=;y1<=n;y1++){
for(int x2=x1+;x2<=n;x2++){
for(int y2=y1+;y2<=n;y2++){
ans=max(ans,sum[x2][y2]-sum[x1][y2]-sum[x2][y1]+sum[x1][y1]);
}
}
}
}
printf("%d\n",ans); return ;
}
POJ 1050 To the Max 暴力,基础知识 难度:0的更多相关文章
- POJ 1050 To the Max 最大子矩阵和(二维的最大字段和)
传送门: http://poj.org/problem?id=1050 To the Max Time Limit: 1000MS Memory Limit: 10000K Total Submi ...
- poj 1050 To the Max(最大子矩阵之和)
http://poj.org/problem?id=1050 我们已经知道求最大子段和的dp算法 参考here 也可参考编程之美有关最大子矩阵和部分. 然后将这个扩大到二维就是这道题.顺便说一下,有 ...
- poj 1050 To the Max(最大子矩阵之和,基础DP题)
To the Max Time Limit: 1000MSMemory Limit: 10000K Total Submissions: 38573Accepted: 20350 Descriptio ...
- POJ 1050 To the Max -- 动态规划
题目地址:http://poj.org/problem?id=1050 Description Given a two-dimensional array of positive and negati ...
- poj 1050 To the Max (简单dp)
题目链接:http://poj.org/problem?id=1050 #include<cstdio> #include<cstring> #include<iostr ...
- poj 1050 To the Max(线性dp)
题目链接:http://poj.org/problem?id=1050 思路分析: 该题目为经典的最大子矩阵和问题,属于线性dp问题:最大子矩阵为最大连续子段和的推广情况,最大连续子段和为一维问题,而 ...
- poj - 1050 - To the Max(dp)
题意:一个N * N的矩阵,求子矩阵的最大和(N <= 100, -127 <= 矩阵元素 <= 127). 题目链接:http://poj.org/problem?id=1050 ...
- [ACM_动态规划] POJ 1050 To the Max ( 动态规划 二维 最大连续和 最大子矩阵)
Description Given a two-dimensional array of positive and negative integers, a sub-rectangle is any ...
- poj 1050 To the Max
To the Max Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 45906 Accepted: 24276 Desc ...
随机推荐
- 36个炫丽的html5 canvas展示
36个炫丽的html5 canvas展示http://html6game.com/2013/08/03/36-behind-the-html5-canvas-show.shtml 16个最好的CSS3 ...
- python中self,cls
cls主要用在类方法定义,而self则是实例方法. self, cls 不是关键字,完全可以使用自己写的任意变量代替实现一样的效果. 普通的实例方法,第一个参数需要是self,它表示一个具体的实例本身 ...
- WebKit渲染基础(转载 学习中。。。)
概述 WebKit是一个渲染引擎,而不是一个浏览器,它专注于网页内容展示,其中渲染是其中核心的部分之一.本章着重于对渲染部分的基础进行一定程度的了解和认识,主要理解基于DOM树来介绍Render树和R ...
- mysql 前缀索引
计算适合设置索引的长度,直到去重以后在一个固定值. 根据去重以后适合的长度设置索引. 计划查询
- 静态库冲突的解决办法:duplicate symbol
昨天在做微信sdk和xmpp的集成,发现各自单独集成没问题,一起集成却总报错,百度了好一会儿才知道,这应该是库冲突造成的问题 然后参考了很多文章,跟着敲敲一遍,却发现问题多多,最后主要综合结合了这两个 ...
- Hbase之测试数据
info ship user name age height phone addr email dept salary create 'user','info','ship'; put 'user', ...
- 抓包工具Fidder设置(移动端抓包)
1.下载安装fiddler,下载链接:http://fiddler2.com/get-fiddler(我用的是免安装的fiddler2) 2.设置fiddler 打开Fiddler, Tool ...
- Facade 运行机制
举一个常见的例子在routes.php路由文件中的Route就是使用了laravel的Facade; config/app.php 文件中的aliases数组: 再例如其中的mail: 里面只是简单的 ...
- 1.1 ASP.NET MVC简介
1.什么是ASP.NET MVC? (1)它是个怎么样的产品? ASP.NET MVC是微软公司.NET平台上的一个Web开发框架,它为开发者提供了一种构建结构良好的Web应用程序的方式.自2007年 ...
- jmeter 建立一个JMS点对点测试计划
确保所需的jar文件在JMeter的 自由 目录中. 如果他们不是,关闭JMeter, 重启JMeter复制jar文件. 看到 开始 获取详细信息. 测试的设置是1与5线程发送4 thread ...