UVA - 10827 Maximum sum on a torus

发布时间:2016-12-9 21:25:47 编辑:www.fx114.net 分享查询网我要评论
本篇文章主要介绍了"UVA - 10827 Maximum sum on a torus",主要涉及到UVA - 10827 Maximum sum on a torus方面的内容,对于UVA - 10827 Maximum sum on a torus感兴趣的同学可以参考一下。

题意:Maximum Sum 的加强版,多了个可以构成环,那么就把图扩大成4倍,然后枚举每种情况 #include <iostream> #include <cstdio> #include <cstring> using namespace std; const int MAXN = 210; int a[MAXN][MAXN],b[MAXN]; int main() { int n,t; scanf("%d",&t); while (t--) { scanf("%d",&n); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) { scanf("%d",&a[i][j]); a[i+n][j] = a[i][j+n] = a[i+n][j+n] = a[i][j]; } int Max = -123456675; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) { memset(b,0,sizeof(b)); for (int x = 0; x < n; x++) { int sum = 0; for (int y = 0; y < n; y++) { b[y+j] += a[x+i][j+y]; sum += b[y+j]; if (sum > Max) Max = sum; } } } printf("%d\n",Max); } return 0; }

上一篇:camera
下一篇:1064 - Network

相关文章

相关评论