题目1001:A+B for Matrices

时间限制:1 秒

内存限制:32 兆

特殊判题:

提交:15235

解决:6172

题目描述:

This time, you are supposed to find A+B where A and B are two matrices, and then count the number of zero rows and columns.

输入:

The input consists of several test cases, each starts with a pair of positive integers M and N (≤10) which are the number of rows and columns of the matrices, respectively. Then 2*M lines follow, each contains N integers in [-100, 100], separated by a space. The first M lines correspond to the elements of A and the second M lines to that of B.

The input is terminated by a zero M and that case must NOT be processed.

输出:

For each test case you should output in one line the total number of zero rows and columns of A+B.

样例输入:
2 2
1 1
1 1
-1 -1
10 9
2 3
1 2 3
4 5 6
-1 -2 -3
-4 -5 -6
0
样例输出:
1
5
来源:
2011年浙江大学计算机及软件工程研究生机试真题
分析:
读懂题意就OK
 #include<iostream>
#include<queue>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int map[][];
int main(){
int m,n;
while(scanf("%d",&m)&&m){
scanf("%d",&n);
int i,j;
for(i=;i<m;i++){
for(j=;j<n;j++){
scanf("%d",&map[i][j]);
}
}
for(i=;i<m;i++){
for(j=;j<n;j++){
int t;
scanf("%d",&t);
map[i][j]+=t;
}
}
int sum=;
for(i=;i<m;i++){
for(j=;j<n;j++){
if(map[i][j])
break;
}
if(j==n)
sum++;
}
for(i=;i<n;i++){
for(j=;j<m;j++){
if(map[j][i])
break;
}
if(j==m)
sum++;
}
cout<<sum<<endl;
}
return ;
}

九度oj 1001 A+B for Matrices 2011年浙江大学计算机及软件工程研究生机试真题的更多相关文章

  1. 九度oj 1464 Hello World for U 2012年浙江大学计算机及软件工程研究生机试真题

    题目1464:Hello World for U 时间限制:1 秒 内存限制:128 兆 特殊判题:否 提交:3872 解决:1082 题目描述: Given any string of N (> ...

  2. 九度oj 1004 Median 2011年浙江大学计算机及软件工程研究生机试真题

    题目1004:Median 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:14162 解决:3887 题目描述: Given an increasing sequence S of N i ...

  3. 九度oj 1002 Grading 2011年浙江大学计算机及软件工程研究生机试真题

    #include<iostream> #include<queue> #include<cstdio> #include<cstring> #inclu ...

  4. 九度OJ 1019 简单计算器 -- 2006年浙江大学计算机及软件工程研究生机试真题

    题目地址:http://ac.jobdu.com/problem.php?pid=1019 题目描述:     读入一个只包含 +, -, *, / 的非负整数计算表达式,计算该表达式的值. 输入: ...

  5. 九度oj 1034 寻找大富翁 2009年浙江大学计算机及软件工程研究生机试真题

    题目1034:寻找大富翁 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:5323 解决:2123 题目描述:     浙江桐乡乌镇共有n个人,请找出该镇上的前m个大富翁. 输入:     ...

  6. 九度oj 1031 xxx定律 2009年浙江大学计算机及软件工程研究生机试真题

    题目1031:xxx定律 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:5153 解决:3298 题目描述:     对于一个数n,如果是偶数,就把n砍掉一半:如果是奇数,把n变成 3*n ...

  7. 九度oj 1032 ZOJ 2009年浙江大学计算机及软件工程研究生机试真题

    题目1032:ZOJ 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4102 解决:2277 题目描述: 读入一个字符串,字符串中包含ZOJ三个字符,个数不一定相等,按ZOJ的顺序输出,当 ...

  8. 九度oj 1006 ZOJ问题 2010年浙江大学计算机及软件工程研究生机试真题

    题目1006:ZOJ问题 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:16244 解决:2742 题目描述: 对给定的字符串(只包含'z','o','j'三种字符),判断他是否能AC.是 ...

  9. 九度oj 1437 To Fill or Not to Fill 2012年浙江大学计算机及软件工程研究生机试真题

    题目1437:To Fill or Not to Fill 时间限制:1 秒 内存限制:128 兆 特殊判题:否 提交:1488 解决:345 题目描述: With highways availabl ...

随机推荐

  1. EasyUI combobox动态增加选择项

    有需求需要动态的为combobox增加可选项,后来解决方案如下 html如下 <select id="workerList"></select> js 如下 ...

  2. velocity的日志解决问题

    问题描述:velocity使用时,添加了一个非自己想要的日志文件,因此在velocity的配置中需要添加logger. 解决: velocity.properties添加log配置: runtime. ...

  3. 微软2014实习生招聘笔试第2题 the k-th string

    Time Limit: 10000msCase Time Limit: 1000msMemory Limit: 256MB Description Consider a string set that ...

  4. 跨DLL操作fopen的返回值导致出错

    在设置成/MD或/MDd不会导致出错 设置成/MT或/MTd的情况下会导致出错 看了CRT的实现,估计是因为fopen创建了CriticalSection来保护文件,但是在/MT的情况下,一个DLL里 ...

  5. select2 多选设置默认值

    Select2  version 4.0.3  https://select2.github.io   <select id="slroles" ng-model=" ...

  6. 状压DP学习笔记

    有的时候,我们会发现一些问题的状态很难直接用几个数表示,这个时候我们就会用到状压dp啦~~. 状压就是状态压缩,就是讲原本复杂难以描述的状态用一个数或者几个数来表示qwq.状态压缩是一个很常用的技巧, ...

  7. 4.client、offset、scroll系列

    client.offset.scroll系列 他们的作用主要与计算盒模型.盒子的偏移量和滚动有关 clientTop 内容区域到边框顶部的距离 ,说白了,就是边框的高度 clientLeft 内容区域 ...

  8. [SinGuLaRiTy] 关于博客

    由于博主主要使用Chrome内核的浏览器进行博客页面的代码优化,因此有些功能可能会因为浏览器的差异而无法正常运行,博主对此也非常无奈啊:Windows的IE浏览器的兼容性实在是太差了...... 尽管 ...

  9. [转] 翻译130+VIM基本命令

    基础 :e filename 在编辑器中打开一个文件 :w 保存文件 :q 退出vim :q! 退出但不保存 :x 写文件(如果有做修改)并退出 :sav filename 保存为 . 在正常模式中重 ...

  10. python3之循环

    本节主要介绍python中循环语句的用法以及其他一些语句exec等,文章后面附有之前的文章: 循环语句 if是值执行一次而循环时在条件满足情况下可以执行相同语句多次:使用循环可以轻松实现序列,词典等的 ...