HUAWEI OD Machine Test-Explore Plot Establishment-2022Q4 Volume A-Py/Java/JS

Given a plot of n*m, which is equivalent to a two-dimensional array of n*m, the value of each element represents the power generation of this small plot; seek to build a power station with a square side length c on this plot, and generate electricity The number of plots whose quantity satisfies the target electricity k.

Enter a description:

The first line is four positive integers separated by spaces, representing n, m, ck respectively

The following n lines of integers represent the power generation of each plot

Output description:

Output the number of plots that meet the criteria

Example:

enter:

2 5 2 6 // nmck, each line below is the power generation per grid of n*m plots

1 3 4 5 8

2 3 6 7 1

output:

4

illustrate:

Areas that meet the conditions are as follows

The first:

1 3

2 3

The second type:

3 4

3 6

The third type:

4 5

6 7

The fourth type:

5 8

7 1

java code

import java.util.Scanner;
import java.util.*;
import java.util.stream.Collectors;
 
public class Main { 
    public static void main(String[] args) {
        //处理输入
        Scanner in=new Scanner(System.in); 
        List<Integer> params =Arrays.stream(in.nextLine().split(" "))
                .map(In

Guess you like

Origin blog.csdn.net/miao_9/article/details/130235475