HDU 1559 最大子矩阵
来源:互联网 发布:南京 网络问政 编辑:程序博客网 时间:2024/05/20 06:30
题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=1559
暴力枚举就行了,不过记住上次的和然后在求解会快一些
代码如下:
#include <iostream>#include <cstdio>#include <cstdlib>#include <cmath>#include <cstring>#include <string>#include <algorithm>#include <vector>#include <set>#include <map>#include <queue>using namespace std;/*freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);*/int xh[1010][1010];int dp[1010][1010];int main(){ int i,j,k,n,m,a,b,t,max,temp; cin>>t; while(t--) { scanf("%d%d%d%d",&n,&m,&a,&b); for(i=1;i<=n;i++) for(j=1;j<=m;j++) scanf("%d",&xh[i][j]); max=dp[1][1]=0; for(i=1;i<=a;i++) for(j=1;j<=b;j++) dp[1][1]+=xh[i][j]; for(i=1;i<=n-a+1;i++) { if(i!=1) { temp=0; for(k=1;k<=b;k++) temp+=xh[i+a-1][k]-xh[i-1][k]; dp[i][1]=dp[i-1][1]+temp; if(max<dp[i][1]) max=dp[i][1]; } for(j=2;j<=m-b+1;j++) { temp=0; for(k=i;k<i+a;k++) temp+=xh[k][j-1+b]-xh[k][j-1]; dp[i][j]=dp[i][j-1]+temp; if(max<dp[i][j]) max=dp[i][j]; } } printf("%d\n",max); } return 520;}
- 最大子矩阵 hdu 1559
- HDU 1559 最大子矩阵
- HDU 1559 最大子矩阵
- HDU 1559 最大子矩阵
- hdu 1559 最大子矩阵
- HDU 1559 最大子矩阵
- HDU-1559最大子矩阵
- hdu 1559 最大子矩阵
- HDU 1559 最大子矩阵
- hdu 1559 最大子矩阵
- hdu 1559 最大子矩阵
- HDU 1559 最大子矩阵
- hdu 1559最大子矩阵
- HDU 1559 最大子矩阵
- HDU 1559 最大子矩阵
- HDU 1559 最大子矩阵
- HDU 1559 最大子矩阵
- hdu-1559 最大子矩阵
- linux里自己安装DNS配置 的步奏和理解
- 叫不叫大数据无所谓,贵在坚持
- OC中的常见关键字及一些基础概念
- JS中改变时间
- C++ 字符串UTF8与GBK转化
- HDU 1559 最大子矩阵
- win7 64位系统 注册 ocx控件
- 学习日记-策略模式
- 配置NDK syntax error: unexpected end of file 解决
- 谈学习中的改变——有病要诊断,有药要服用
- JavaScript中Array(数组)的属性和方法
- JSP网站利用花生壳在公网上进行访问
- java中Exception in thread "main" java.util.NoSuchElementException
- 批量杀死 MySQL 连接