To The Max &&http://acm.hdu.edu.cn/showproblem.php?pid=1081
2012-01-10 08:47
519 查看
这道题很扯淡,,没有说有多组测试数据,却又多组测试数据,,,而且还是以输入0时为结束。。。
#include<iostream>
#include<string.h>
using namespace std;
int dp[101][101];
int b[101];
int main()
{ int n;
while(cin>>n&&n)
{ memset(dp,0,sizeof(dp));
for(int i=0;i!=n;++i)
for(int j=0;j!=n;++j)
cin>>dp[i][j];
int max=0;
for(int i=0;i<n;++i)
{
for(int j=i;j<n;++j)
{ int sum=0;
for(int k=0;k<n;++k)
b[k]+=dp[j][k];
for(int s=0;s<n;++s)
{ sum+=b[s];
if(sum>max) max=sum;
if(sum<0) sum=0;
}
}
memset(b,0,sizeof(b));
}
cout<<max<<endl;
}return 0;
}
#include<iostream>
#include<string.h>
using namespace std;
int dp[101][101];
int b[101];
int main()
{ int n;
while(cin>>n&&n)
{ memset(dp,0,sizeof(dp));
for(int i=0;i!=n;++i)
for(int j=0;j!=n;++j)
cin>>dp[i][j];
int max=0;
for(int i=0;i<n;++i)
{
for(int j=i;j<n;++j)
{ int sum=0;
for(int k=0;k<n;++k)
b[k]+=dp[j][k];
for(int s=0;s<n;++s)
{ sum+=b[s];
if(sum>max) max=sum;
if(sum<0) sum=0;
}
}
memset(b,0,sizeof(b));
}
cout<<max<<endl;
}return 0;
}
相关文章推荐
- find the safest road&&http://acm.hdu.edu.cn/showproblem.php?pid=1596
- Buy the Ticket&&http://acm.hdu.edu.cn/showproblem.php?pid=1133
- The 36th ACM/ICPC Asia Regional Beijing Site&&http://acm.hdu.edu.cn/showproblem.php?pid=4046
- Max Sum &&http://acm.hdu.edu.cn/showproblem.php?pid=1003
- Quoit Design&&http://acm.hdu.edu.cn/showproblem.php?pid=1007
- 找规律。。&&http://acm.hdu.edu.cn/showproblem.php?pid=1097
- Happy 2004&&http://acm.hdu.edu.cn/showproblem.php?pid=1452
- Choose the best route(http://acm.hdu.edu.cn/showproblem.php?pid=2680)
- Clairewd’s message&&http://acm.hdu.edu.cn/showproblem.php?pid=4300
- 最小路径覆盖&&http://acm.hdu.edu.cn/showproblem.php?pid=4160
- HDU Today&&http://acm.hdu.edu.cn/showproblem.php?pid=2112
- http://acm.hdu.edu.cn/showproblem.php?pid=2680&&Choose the best route
- http://acm.hdu.edu.cn/webcontest/contest_showproblem.php?pid=1004&ojid=1&cid=6866&hide=1&problem=Pro
- (博客搬迁啦~)Max Sum Plus Plus(http://acm.hdu.edu.cn/showproblem.php?pid=1024)
- Substrings &&http://acm.hdu.edu.cn/showproblem.php?pid=1238
- Holedox Eating &&http://acm.hdu.edu.cn/showproblem.php?pid=4302
- I NEED A OFFER! &&http://acm.hdu.edu.cn/showproblem.php?pid=1203
- Robberies&&http://acm.hdu.edu.cn/showproblem.php?pid=2955
- A + B Problem II &&http://acm.hdu.edu.cn/showproblem.php?pid=1002
- Number Sequence&&http://acm.hdu.edu.cn/showproblem.php?pid=1005