九度oj 1001 A+B for Matrices 2011年浙江大学计算机及软件工程研究生机试真题
题目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年浙江大学计算机及软件工程研究生机试真题的更多相关文章
- 九度oj 1464 Hello World for U 2012年浙江大学计算机及软件工程研究生机试真题
题目1464:Hello World for U 时间限制:1 秒 内存限制:128 兆 特殊判题:否 提交:3872 解决:1082 题目描述: Given any string of N (> ...
- 九度oj 1004 Median 2011年浙江大学计算机及软件工程研究生机试真题
题目1004:Median 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:14162 解决:3887 题目描述: Given an increasing sequence S of N i ...
- 九度oj 1002 Grading 2011年浙江大学计算机及软件工程研究生机试真题
#include<iostream> #include<queue> #include<cstdio> #include<cstring> #inclu ...
- 九度OJ 1019 简单计算器 -- 2006年浙江大学计算机及软件工程研究生机试真题
题目地址:http://ac.jobdu.com/problem.php?pid=1019 题目描述: 读入一个只包含 +, -, *, / 的非负整数计算表达式,计算该表达式的值. 输入: ...
- 九度oj 1034 寻找大富翁 2009年浙江大学计算机及软件工程研究生机试真题
题目1034:寻找大富翁 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:5323 解决:2123 题目描述: 浙江桐乡乌镇共有n个人,请找出该镇上的前m个大富翁. 输入: ...
- 九度oj 1031 xxx定律 2009年浙江大学计算机及软件工程研究生机试真题
题目1031:xxx定律 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:5153 解决:3298 题目描述: 对于一个数n,如果是偶数,就把n砍掉一半:如果是奇数,把n变成 3*n ...
- 九度oj 1032 ZOJ 2009年浙江大学计算机及软件工程研究生机试真题
题目1032:ZOJ 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4102 解决:2277 题目描述: 读入一个字符串,字符串中包含ZOJ三个字符,个数不一定相等,按ZOJ的顺序输出,当 ...
- 九度oj 1006 ZOJ问题 2010年浙江大学计算机及软件工程研究生机试真题
题目1006:ZOJ问题 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:16244 解决:2742 题目描述: 对给定的字符串(只包含'z','o','j'三种字符),判断他是否能AC.是 ...
- 九度oj 1437 To Fill or Not to Fill 2012年浙江大学计算机及软件工程研究生机试真题
题目1437:To Fill or Not to Fill 时间限制:1 秒 内存限制:128 兆 特殊判题:否 提交:1488 解决:345 题目描述: With highways availabl ...
随机推荐
- Mac安装Tomcat
1. 到Tomcat官网下载,如下找tar格式文件: http://ftp.twaren.net/Unix/Web/apache/tomcat/tomcat-8/v8.0.41/bin/apache- ...
- asp.net——地址栏传递中文参数乱码解决方案
地址栏传递中文参数乱码解决方案: 很多人在使用地址栏传递参数的时候都会遇到一个麻烦的问题(参数为中文时乱码了),那要怎么解决呢? 其实解决这个问题也不怎么难,无非就是给要传递的中文参数一个编码解码的过 ...
- selenium爬取网易云
from selenium import webdriver from selenium.webdriver import ActionChains from selenium.webdriver.c ...
- Jenkins 主题分享
写在前面的话 Jenkins 现在是我使用的最多的 CI/CD 工具,但是一直无法接受他的前端,于是闲暇之余查了一些关于 Jenkins 更换样式的方法,于是自己给他写了个套子,感兴趣的老哥以下是项目 ...
- Bitnami WordPress如何让默认URL指向WordPress目录?
Bitnami WordPress下载地址:https://bitnami.com/stack/wordpress/installer ,根据自己操作系统选择对应版本,我是windows server ...
- 16、xtrabackup 增量备份及恢复
备份命令如下 备份命令如下 全量备份 # innobackupex -p123123 /backup # ls /backup 2017-04-08_13-36-11 增量备份或差量备份 # inn ...
- JQuery easyui里面的自动完成autocomplete插件
默认功能 当您在输入域中输入时,自动完成(Autocomplete)部件提供相应的建议.在本实例中,提供了编程语言的建议选项,您可以输入 "ja" 尝试一下,可以得到 Java 或 ...
- 【转】MVC,MVP 和 MVVM 的图示
复杂的软件必须有清晰合理的架构,否则无法开发和维护. MVC(Model-View-Controller)是最常见的软件架构之一,业界有着广泛应用.它本身很容易理解,但是要讲清楚,它与衍生的 MVP ...
- 用 gdb 和 qemu 调试 grub
因为qemu内置了gdbserver,所以我们可以用gdb调试qemu虚拟机上执行的代码,而且不受客户机系统限制. 以下内容是我调试 grub 0.97 时的一份笔记. 准备 qemu, gdb,以及 ...
- python 获取文件路径
一种是获取当前你正在操作文件的路径 一种是获取你执行文件的路径(比如你在你调用的包里面更改了,执行的时候就不会找你的包的路径,而是你执行文件的路径)