题意:

求一个最大子矩阵和。

思路:

枚举行区间,然后求一个最大子序列和。

贴一发挫code…

#include <iostream>
#include <cstdio>
#include <string.h>
#include <algorithm>
using namespace std;
typedef __int64 LL; const int N=1e2+10; int a[N][N];
int dp[N]; int main()
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
scanf("%d",&a[i][j]);
int ans;
ans=a[1][1];
for(int k=1;k<=n;k++)
{
for(int i=k;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(i==k)
dp[j]=a[i][j];
else
dp[j]+=a[i][j];
}
int tmax=0;
for(int j=1;j<=n;j++)
{
if(tmax>0)
tmax+=dp[j];
else
tmax=dp[j];
if(tmax>ans)
ans=tmax;
}
}
}
printf("%d\n",ans);
return 0;
}
/*
4
0 -2 -7 0
9 2 -6 2
-4 1 -4 1
-1 8 0 -2
*/

最新文章

  1. Unity3D研究院之拓展系统自带组件的Inspector视图
  2. HDU 5876 关于补图的bfs
  3. 象写程序一样写博客:搭建基于github的博客
  4. Linux下c++中的atoi、atol、atoll、atof函数调用实例
  5. 【Log4j】 log4j.properties 使用
  6. bzoj2426
  7. python数据类型和3个重要函数
  8. 学习使用Vim(一)
  9. Java程序初始化的顺序
  10. php5.6在yum下安装redis
  11. 201521123016《Java程序设计》第10周学习总结
  12. Caused by: java.sql.BatchUpdateException: You have an error in your SQL syntax; check the manual tha
  13. (译文)开始学习Vue.js特性--Scoped Slots
  14. log4j配置及使用
  15. Python基础知识1-基础语法
  16. docker 安装mysql示例
  17. kali linux 入侵window实例
  18. [可能没有默认的字体]Warning: imagettfbbox() [function.imagettfbbox]: Invalid font filename...
  19. Maven安装及MyEclipse中使用Maven
  20. InnoDB: The log sequence number in ibdata files does not match

热门文章

  1. 《C++ Primer Plus》学习笔记9
  2. SolidEdge如何绘制变化半径倒圆角
  3. PHP中文分词扩展 SCWS
  4. Autolayout和VFL
  5. PHP生成excel(2)
  6. error C2065: &#39;CArchiveStream&#39; : undeclared identifier
  7. grunt简单教程
  8. VC断点失败的原因之中的一个
  9. python day - 19 抽象类 接口类 多态 封装
  10. CentOS笔记-其他杂记