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 }
- 2929: [Poi1999]洞穴攀行
- SQL Server 执行计划缓存
- 1081: [SCOI2005]超级格雷码
- 1715: [Usaco2006 Dec]Wormholes 虫洞
- 博弈论入门之斐波那契博弈
- 3018: [Usaco2012 Nov]Distant Pastures
- 1755: [Usaco2005 qua]Bank Interest
- SQL Server 重新组织生成索引
- 3386/1752: [Usaco2004 Nov]Til the Cows Come Home 带奶牛回家
- 洛谷P2197 nim游戏(Nim游戏)
- SQL Server 索引和表体系结构(聚集索引+非聚集索引)
- 3384/1750: [Usaco2004 Nov]Apple Catching 接苹果
- 1702: [Usaco2007 Mar]Gold Balanced Lineup 平衡的队列
- 1455: 罗马游戏
- 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 数组属性和方法
- Thinkphp自定义生成缩略图尺寸的方法
- Yii框架中使用PHPExcel的方法分析
- 详解python使用pip安装第三方库(工具包)速度慢、超时、失败的解决方案
- Laravel框架自定义分页样式操作示例
- 使用composer 安装 laravel框架的方法图文详解
- laravel5.6 框架操作数据 Eloquent ORM用法示例
- Python版名片管理系统
- docker-compose部署php项目实例详解
- Linux下通过sed命令对kv方式的配置文件进行修改
- laravel5.6框架操作数据curd写法(查询构建器)实例分析
- PHP基于timestamp和nonce实现的防止重放攻击方案分析
- 怎么在 Linux 中查找一个命令或进程的执行时间
- laravel5.6 框架邮件队列database驱动简单demo示例
- php layui实现前端多图上传实例
- 解决Centos7下crontab+shell脚本定期自动删除文件问题