九度OJ-1001-A+B矩阵-有些小技巧
题目1001:A+B for Matrices
时间限制:1 秒
内存限制:32 兆
特殊判题:否
提交:22974
解决:9099
- 题目描述:
-
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
- 2 2
- 样例输出:
-
- 1
- 5
- 1
- #include <stdio.h>
- int ma[][];
- int mb[][];
- int main() {
- int a, b;
- while(scanf("%d", &a)) {
- if(a == ) return ;
- scanf("%d", &b);
- for(int i = ; i < a; i++) {
- for(int j = ; j < b; j++) {
- scanf("%d", &ma[i][j]);
- }
- }
- for(int i = ; i < a; i++) {
- for(int j = ; j < b; j++) {
- scanf("%d", &mb[i][j]);
- mb[i][j] += ma[i][j];
- }
- }
- // sum
- int su = ;
- int co = ;
- for(int i = ; i < a; i++) {
- for(int j = ; j < b; j++) {
- if(mb[i][j] != ){
- co++;
- // printf("%d %d\n", i, j);
- break;
- }
- }
- if(co == ) {
- su++;
- // printf("%d %d\n", i, su);
- }
- else co = ;
- }
- co = ;
- for(int j = ; j < b; j++) {
- for(int i = ; i < a; i++) {
- if(mb[i][j] != ) {
- co++;
- break;
- }
- }
- if(co == ) {
- su++;
- }
- else co = ;
- }
- printf("%d\n", su);
- }
- return ;
- }
九度OJ-1001-A+B矩阵-有些小技巧的更多相关文章
- 九度OJ 1001:A+B for Matrices
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:17682 解决:7079 题目描述: This time, you are supposed to find A+B where A and ...
- 九度oj 1001 A+B for Matrices 2011年浙江大学计算机及软件工程研究生机试真题
题目1001:A+B for Matrices 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:15235 解决:6172 题目描述: This time, you are supposed ...
- 九度OJ 1534 数组中第K小的数字 -- 二分查找
题目地址:http://ac.jobdu.com/problem.php?pid=1534 题目描述: 给定两个整型数组A和B.我们将A和B中的元素两两相加可以得到数组C. 譬如A为[1,2],B为[ ...
- 【九度OJ】题目1474:矩阵幂 解题报告
[九度OJ]题目1474:矩阵幂 解题报告 标签(空格分隔): 九度OJ http://ac.jobdu.com/problem.php?pid=1474 题目描述: 给定一个n*n的矩阵,求该矩阵的 ...
- 【九度OJ】题目1193:矩阵转置 解题报告
[九度OJ]题目1193:矩阵转置 解题报告 标签(空格分隔): 九度OJ http://ac.jobdu.com/problem.php?pid=1193 题目描述: 输入一个N*N的矩阵,将其转置 ...
- 【九度OJ】题目1191:矩阵最大值 解题报告
[九度OJ]题目1191:矩阵最大值 解题报告 标签(空格分隔): 九度OJ http://ac.jobdu.com/problem.php?pid=1191 题目描述: 编写一个程序输入一个mXn的 ...
- 九度OJ 题目1384:二维数组中的查找
/********************************* * 日期:2013-10-11 * 作者:SJF0115 * 题号: 九度OJ 题目1384:二维数组中的查找 * 来源:http ...
- 九度oj题目&吉大考研11年机试题全解
九度oj题目(吉大考研11年机试题全解) 吉大考研机试2011年题目: 题目一(jobdu1105:字符串的反码). http://ac.jobdu.com/problem.php?pid=11 ...
- 【九度OJ】题目1069:查找学生信息 解题报告
[九度OJ]题目1069:查找学生信息 解题报告 标签(空格分隔): 九度OJ [LeetCode] http://ac.jobdu.com/problem.php?pid=1069 题目描述: 输入 ...
- 【九度OJ】题目1174:查找第K小数 解题报告
[九度OJ]题目1174:查找第K小数 解题报告 标签(空格分隔): 九度OJ 原题地址:http://ac.jobdu.com/problem.php?pid=1174 题目描述: 查找一个数组的第 ...
随机推荐
- API验证插件
前言 如果在访问某WebAPI过程中request信息被他人截获,若是get请求获取数据还好,如果是post提交数据,势必威胁数据安全,所以对于一个对安全性要求较高的API来说,对每个请求做身份验证显 ...
- provider和consumer配置参数的优先级
<dubbo:service>和<dubbo:reference>存在一些相同的参数,例如:timeout,retries等,那么哪个配置的优先级高呢? consumer合并u ...
- 漫谈moosefs中cgi各项的意义
原创:http://www.cnblogs.com/bugutian/p/6869278.html 转载请注明出处 一.先上一张图 二.解释 1. Metadata Servers (masters) ...
- MySQL设置白名单教程
1 登录mysql mysql -h host -u username -p password 2 切换至mysql库 use mysql; 3 查看当前允许登录IP及用户 select Host,U ...
- Python获取时间戳
import datetime as dt dt.datetime.now().microsecond
- python(3)之字符串
字符串常用操作如下: name="huang yuqing"print(name.count("h"))#计算包含字符的个数print(name.capital ...
- Jquery如何禁止鼠标右键菜单
jquery中使用contextmenu事件,如果返回true,则允许右键菜单:如果返回false,则禁止右键菜单 导入文件 <script type="text/javascript ...
- C++11 并发之std::thread std::mutex
https://www.cnblogs.com/whlook/p/6573659.html (https://www.cnblogs.com/lidabo/p/7852033.html) C++:线程 ...
- Django+Xadmin+Echarts动态获取数据legend颜色显示灰色问题已解决
前段时间做的使用Django的Xadmin后台和百度Echarts进行后台数据可视化,功能虽然实现,展示出来的legend图例,都是灰色的,只有鼠标放上去才会显示彩色的.百度都快被我刨穿了,看到有类似 ...
- OO第一阶段总(休)结(养)分(生)析(息)
第一次作业: 这是一次让我认识到ddl面前潜力真的可以无限大的作业. 一直以为OO是一门和数据结构一样先用几周的时间讲讲Java然后写写”Hello World”小程序再开始讲正课的我(我也不知道为什 ...