题目 代码 python">class Solution: def func(self, input_args, area_list): count = 0 for i in range(input_args[0] - input_args[2] + 1): for j in range(input_args[1] - input_args[2] + 1): count += 1 if self.area_compute(area_list,i,j,input_args[2],input_args[3]) else 0 print(count) return count def area_compute(self, area_list, x, y, length, value): compute_value = 0 if length == 1: return True if area_list[x][y] >= value else False else: for i in range(length): compute_value += area_list[x+i][y] if compute_value >= value: return True for i in range(length): compute_value += area_list[x][y+i] if compute_value >= value: return True return False s = Solution() # input_args = [2, 5, 2, 6] # area_list = [[1, 3, 4, 5, 8], [2, 3, 6, 7, 1]] input_args = [2, 5, 1, 6] area_list = [[1, 3, 4, 5, 8], [2, 3, 6, 7, 1]] s.func(input_args, area_list)