Sample Input
2
2 2
1 1
0 0
3 3
1 0 1
0 0 1
1 1 0
Sample Output
2
2
2 2
1 1
0 0
3 3
1 0 1
0 0 1
1 1 0
Sample Output
2
5
import java.io.*;
import java.util.*;
public class PracticeIV {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
while((a--)>0){
int n = sc.nextInt();
int m = sc.nextInt();
int[][] b = new int[n][m];
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
b[i][j] = sc.nextInt();
}
}
int count = 0;
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
if(b[i][j]==1)
count++;
}
}
System.out.println(count);
}
}
}
我这代码一直报:Memory Limit Exceeded