POJ 1050 To the Max(枚举+动规)
来源:互联网 发布:c语言用什么编译器好 编辑:程序博客网 时间:2024/05/17 07:51
题目:
http://poj.org/problem?id=1050
题解:
此题转化成一维后就相当于求最大连续子序列了,可以枚举所有的行组合,把枚举到的起始行到终止行的值按列相加存入一个一维数组。
代码:
#include<cstdio>#include<cstring>int a[101][101];int value[101];int dp[101];int max(int a,int b){return a>b?a:b;}int main(){int N;while(~scanf("%d",&N)){int i,j;for(i=1;i<=N;i++){for(j=1;j<=N;j++){scanf("%d",&a[i][j]);}}int ans=-100000000;for(i=1;i<=N;i++)//i为起始行{for(j=i;j<=N;j++)//j为终止行{int ti,tj;memset(dp,0,sizeof(dp));for(tj=1;tj<=N;tj++){value[tj]=0;for(ti=i;ti<=j;ti++){value[tj]+=a[ti][tj];}}for(ti=1;ti<=N;ti++){dp[ti]=max(value[ti],value[ti]+dp[ti-1]);ans=max(dp[ti],ans);}}}printf("%d\n",ans);}return 0;}
0 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(dp)
- POJ 1050 to the max(dp)
- poj 1050 To the Max (dp)
- 【POJ 1050】To the Max(dp)
- 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
- POJ 1050 To the Max
- IIS防盗链:ISAPI Rewrite图片防盗链规则写法
- undone有关链表
- db2日期和时间常用汇总
- uva 11578 - Situp Benches(dp+输出路径)
- SVN标准目录结构 的一些网文
- POJ 1050 To the Max(枚举+动规)
- iOS设备是否越狱的判断代码
- Map集合类比较
- linux shell编程awk、sed调用方法
- mesh repair
- AVR_BootLoader设计及实现
- Ubuntu操作命令备忘录(不定时更新)
- spfa模板
- 阻塞队列(BlockingQueue)源码分析