fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. int [][] gr = new int [1001][1001];
  10. Scanner in = new Scanner(System.in);
  11. int n = in.nextInt();
  12. int ans = 0;
  13. for (int i=0; i<n; i++) {
  14. for (int j=0; j<n; j++) {
  15. gr[i][j] = in.nextInt();
  16. }
  17. }
  18. for (int i=0; i<n; i++) {
  19. int cnt = 0;
  20. for (int j=0; j<n; j++) {
  21. if (gr[i][j] == 1) cnt++;
  22. }
  23. if (cnt==1) ans++;
  24. }
  25. System.out.println(ans);
  26. }
  27. }
Success #stdin #stdout 0.06s 2184192KB
stdin
3
0 1 1
1 0 1
1 0 0 
stdout
1