poj 1050 To the Max_dp求最大子矩阵和
来源:互联网 发布:科胜通软件 编辑:程序博客网 时间:2024/06/10 16:39
题意:求最大子矩阵和
利用dp[i]每次向下更新,构成竖起的单条矩阵,再按不小于零就加起来来更新,构成更大的矩阵
#include <iostream>#include<cstdio>#include<cstring> using namespace std;#define N 110int map[N][N],dp[N];int main(int argc, char** argv) {int n,i,j,k,maxn,ans;while(scanf("%d",&n)!=EOF){ans=-9999999;for(i=0;i<n;i++)for(j=0;j<n;j++)scanf("%d",&map[i][j]);for(i=0;i<n;i++){memset(dp,0,sizeof(dp));for(j=i;j<n;j++){for(k=0;k<n;k++){dp[k]+=map[j][k];}maxn=-1;for(k=0;k<n;k++){maxn=maxn<0?dp[k]:maxn+dp[k];if(maxn>ans)ans=maxn;}}}printf("%d\n",ans);}return 0;}
- poj 1050 To the Max_dp求最大子矩阵和
- POJ 1050 To the Max (动态规划——求最大子矩阵和)
- poj 1050 To the Max 最大子矩阵和
- poj 1050 To the Max(最大子矩阵和)
- poj 1050 To the Max(最大子矩阵和)
- POJ 1050-To the Max(最大子矩阵和)
- POJ 1050 To the Max (最大子矩阵和)
- [POJ 1050] To the Max DP+最大子矩阵和
- 【最大子矩阵和】poj 1050 To the Max
- poj 1050 To the Max(最大子矩阵和)
- poj 1050 To the Max -- 最大子矩阵和
- POJ 1050-To the Max(最大子矩阵和)
- POJ 1050 To the Max【求最大的子矩阵和同上一篇数组中最大连续和】
- POJ 1050 To the Max(dp 最大子矩阵和/最大子段和问题)
- To The Max(求最大子矩阵和)
- To the max(求最大子矩阵和)
- poj 1050 求矩阵最大的子矩阵和 DP
- POJ 1050 To the max 最大子矩阵
- Nuttx 移植到 Renesas RX62N
- 上采样与插值滤波器
- libSVM介绍(二)
- 2013.11.26
- Java线程的两种创建方式及优劣比较
- poj 1050 To the Max_dp求最大子矩阵和
- Spring学习笔记:Spring 框架概述
- Java局部变量的引用
- libSVM应用举例
- 深度理解Oracle10g中UNDO_RETENTION参数的使用
- iPhone上关于相机拍照的图片的imageOrientation的问题
- 一位女程序员的奋斗路程
- C#,sqlite批量操作速度优化
- 探索Windows Mobile编译过程 .