码迷,mamicode.com
首页 > 其他好文 > 详细

HDU buildings

时间:2015-07-25 21:16:26      阅读:106      评论:0      收藏:0      [点我收藏+]

标签:

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

Standard input will contain multiple test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow. 
The first line of each test case contains two 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 that grid, 0 stands for white color, while 1 stands for green.
 
Output
 Results should be directed to standard output. For each case, output an 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

 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 }

 

HDU buildings

标签:

原文地址:http://www.cnblogs.com/l20902/p/4676463.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!