-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2-1-4.java
More file actions
27 lines (26 loc) · 847 Bytes
/
2-1-4.java
File metadata and controls
27 lines (26 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import java.util.Scanner;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int k = scanner.nextInt();
ArrayList<ArrayList<Integer>> A = new ArrayList<ArrayList<Integer>>(n);
for (int i = 0; i < n; i++) {
ArrayList<Integer> row = new ArrayList<Integer>(n);
for (int j = 0; j < n; j++) {
row.add(scanner.nextInt());
}
A.add(row);
}
int answer = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (A.get(i).get(j) == k) {
answer++;
}
}
}
System.out.println(answer);
}
}