ACM: uva 10827 -&…
来源:互联网 发布:ios 网络请求第三方 编辑:程序博客网 时间:2024/05/16 10:42
Maximum sum on a torus
A grid that wraps both horizontally and vertically is called atorus. Given a torus where each cell contains an integer, determinethe sub-rectangle with the largest sum. The sum of a sub-rectangleis the sum of all the elements in that rectangle. The grid belowshows a torus where the maximum sub-rectangle has been shaded.
The first line in the input contains the number of test cases(at most 18). Each case starts with an integer N (1≤N≤75)specifying the size of the torus (always square). Then follows Nlines describing the torus, each line containing N integers between-100 and 100, inclusive.
Output
For each test case, output a line containing a single integer:the maximum sum of a sub-rectangle within the torus.
Sample input
2
5
1 -1 0 0 -4
2 3 -2 -3 2
4 1 -1 5 0
3 -2 1 -3 2
-3 2 4 1 -4
3
1 2 3
4 5 6
7 8 9
Sample output
15
45
题意: 现在给出一个矩形的圆柱面, 每一个格子都有一个整数, 现在要你求出最大和子矩阵.
解题思路:
代码:
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
#define MAX 155
const int INF = (1<<29);
int n, m;
int g[MAX][MAX], sum[MAX][MAX];
inline int max(int a, int b)
{
}
int main()
{
//
}
- ACM: uva 10827 -&…
- ACM: uva 11210 &n…
- ACM: uva 11389 -&…
- ACM: uva 1325 -&n…
- ACM: uva 10763 -&…
- ACM: uva 1432 -&n…
- ACM: uva 1362 -&n…
- ACM: uva 11361 -&…
- ACM: uva 1069 -&n…
- ACM: uva 11426 -&…
- ACM: 极其简单题 uva&nb…
- ACM: uva 10253 - Series-Parallel…
- ACM: LA 3266 -&nb…
- ACM: poj 2786 -&n…
- ACM: poj 3972 -&n…
- ACM: uva 1335 - Beijing Guards
- ACM: uva 10391 - Compound Words
- ACM: uva 10534 - Wavio Sequence
- ACM: uva 1450 - Airport
- ACM: uva 1467 - Installations
- ACM: LA 3266 -&nb…
- ACM: uva 11389 -&…
- ACM: uva 1325 -&n…
- ACM: uva 10827 -&…
- [蓝桥杯]常用算法-递归法
- ACM: uva 10125 - Sumsets
- Java发展历史
- boost的shared_ptr循环引用(1)
- Iwfu-贝塞尔曲线
- ACM: uva 10763 -&…
- ACM: uva 10391 - Compound Words
- ACM: uva 1451 - Average