Problem Description
We divide the hznu Campus into n*m grids. As can see from the picture below, the green grids represent the buidings. Given the size of the Hznu Campus, and the color of each grid, you should count how many green grids in the n*m grids.
Input
Standard input would contain multiple test cases. The first line of the input was a single integer T which is the number of test cases. T test Cases follow.
The first line of all test case contains, integers n and M (1<=n,m<=100), the size of the campus. Then follow n lines, each line containing M integers. The j-th integer in the i-th line is the color of this grid, 0 stands for white color, while 1 stands for green.
Output
Results should is directed to standard output. For each case, output a integers T, the total green grids in the n*m size campus.
Sample Input
2
2 2
1 1
0 0
3 3
1 0 1
0 0 1
1 1 0
Sample Output
2
5
Water Problem One ~ ~
is a school n*m area, then there are buildings ~
1 representing the building, statistics of the total number of buildings ~
Import Java.util.Scanner; Public classmain{ Public Static void Main(string[] args) {Scanner SC =NewScanner (System.inch);intT =sc.nextint (); while(t-->0){intn =sc.nextint ();intM =sc.nextint ();intsum=0; for(intI=0; i<n;i++) { for(intj=0; j<m;j++) {inta =sc.nextint ();if(a==1) {sum++; }}} System. out. println (sum); } }}
Hdoj/hdu 2560 buildings (hmm ~ water problem)