解题思路:纯暴力此题用Python会超时,建议改用C/C++提交,方法都是一样的
注意事项:
参考代码:
def SUM(i,j,x,y): # list子矩阵中的左上点和右下点 s = 0 for m in range(i,x+1): for n in range(j,y+1): s += list[m][n] return s N = int(input()) list = [] for _ in range(N): temp = [int(i) for i in input().split()] list.append(temp) result = [] for i in range(N): for j in range(N): for x in range(i,N): for y in range(j,N): result.append(SUM(i,j,x,y)) print(max(result))
0.0分
1 人评分