POJ-1050-To the Max
来源:互联网 发布:mysql 修复数据库 编辑:程序博客网 时间:2024/05/01 22:38
题目是说给你一个矩阵,让你求出一个子矩阵,满足和最大
比较简单的DP,枚举列的起点与终点,然后DP计算即可
代码:
#include<cstdio>#include<cstring>#include<iostream>using namespace std;const int maxn=110;int n,a[maxn][maxn],sum[maxn][maxn],dp[maxn];int main(){ while(scanf("%d",&n)!=EOF) {for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) {scanf("%d",&a[i][j]);sum[i][j]=sum[i][j-1]+a[i][j]; }int ans=-1<<29;for(int i=1;i<=n;i++) for(int j=1;j<i;j++) {dp[1]=sum[1][i]-sum[1][j-1];for(int k=2;k<=n;k++){ dp[k]=max(sum[k][i]-sum[k][j-1]+dp[k-1],sum[k][i]-sum[k][j-1]); ans=max(ans,dp[k]);} }printf("%d\n",ans); } return 0;}
- 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
- 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
- poj 1050 to the max
- poj-1050- To the Max
- POJ-1050-To the Max
- POJ 1050 To the Max
- SuperMemo POJ3580
- 香港主机空间搜索引擎会不收录吗?
- Apache CXF2+Spring2.5轻松实现WebService[附源码]
- #坑#小米4.0稳定版不能获取root权限
- IOS开发笔记 - 先有鸡,还是先有蛋?相互引用的奇遇!
- POJ-1050-To the Max
- Android开发(11)-利用listview控件显示person表中的所有数据(并实现点击触发拨号程序)
- UVA 10054 The Necklace(euler)
- 加急审核
- 为什么Hadoop将一定会是分布式计算的未来?
- VC6在对话框里,给控件加提示TIPS——最简单的方法
- 8 个最佳 PHP 库
- ORACLE连接字符串里每个参数的具体意思
- Ubuntu 10.10 安装VIM