Buildings
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 <iostream>
2 using namespace std;
3 int main()
4 {
5 int n,a,b,s,t;
6 cin >> n;
7 for (int i=1;i<=n;i++)
8 {
9 cin >> a >> b;
10 t=0;
11 for (int j=1;j<=a*b;j++)
12 {
13 cin >> s;
14 if (s==1)
15 t++;
16 }
17 cout << t << endl;
18 }
19 return 0;
20 }
- 微信快速开发框架(二) -- 快速开发微信公众平台框架---简介
- LayoutInflater 布局渲染工具原理分析
- 使用Keras在训练深度学习模型时监控性能指标
- 微信快速开发框架(四)-- 体验微信公众平台快速开发框架
- AsyncTask源码解析
- 微信快速开发框架(五)-- 利用快速开发框架,快速搭建微信浏览博客园首页文章
- 对于小批量梯度下降以及如何配置批量大小的入门级介绍
- 数据结构之二叉树
- 微信快速开发框架(六)-- 微信快速开发框架(WXPP QuickFramework)V2.0版本上线--源码已更新至github
- 数据结构之数组
- Android资源动态加载以及相关原理分析
- 微信快速开发框架(七)--发送客服信息,版本更新至V2.2 代码已更新至github
- 微信快速开发框架(八)-- V2.3--增加语音识别及网页获取用户信息,代码已更新至Github
- 微信公众平台快速开发框架 For Core 2.0 beta –JCSoft.WX.Core 5.2.0 beta发布
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法