标签:
Problem Description
We divide the HZNU Campus into N*M grids. As you 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
2 2
1 1
0 0
3 3
1 0 1
0 0 1
1 1 0
Sample Output
2 5
1 # include <stdio.h>
2
3 int main ()
4 {
5 int T, n, m, i, num, sum ;
6 scanf ("%d", &T) ;
7 while (T--)
8 {
9 scanf ("%d%d", &n, &m) ;
10 sum = 0 ;
11 for (i = 0 ; i < n*m ; i++)
12 {
13 scanf ("%d", &num) ;
14 sum += num ;
15 }
16 printf ("%d\n", sum) ;
17 }
18 return 0 ;
19 }
标签:
原文地址:http://www.cnblogs.com/l20902/p/4676463.html