POJ 1050 To the Max
2009-08-07 13:48
309 查看
/*********************************** Problem: POJ 1050 To the Max Time: 0MS Memory: 180K Accepted Time: 2009-08-07 13:44:01 Tip: http://hi.baidu.com/yds_amber/blog/item/5808b0b32f5c0ea2d9335ab3.html ************************************/ #include <stdio.h> #include <string.h> int a[109][109]; int f2(int b[],int n)//求最大子段和 { int i,temp=0,max=0; for(i=1;i<=n;i++) { if(temp>0)temp+=b[i]; else temp=b[i]; if(max<temp)max=temp; } return max; } int f1(int n)//求最大子矩阵和 { int i,j,k,max=0,b[109]; for(i=1;i<=n;i++) { memset(b,0,sizeof(b)); for(j=i;j<=n;j++) { for(k=1;k<=n;k++) b[k]+=a[j][k]; int temp=f2(b,n); if(max<temp)max=temp; } } return max; } int main() { int n; while(scanf("%d",&n)!=EOF) { int i,j; for(i=1;i<=n;i++) for(j=1;j<=n;j++) scanf("%d",&a[i][j]); printf("%d/n",f1(n)); } return 0; }
相关文章推荐
- poj1050 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(最大子矩阵和)
- 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 (简单的线性dp)
- POJ 1050 To the Max
- POJ1050 To the Max
- POJ 1050 To the Max 最大子矩阵和 简单dp
- POJ 1050-To The Max
- POJ 1050 To the Max(DP,最大子矩阵和)
- POJ 1050 To the Max