题目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
样例输出:
1
5
来源:
2011年浙江大学计算机及软件工程研究生机试真题
#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矩阵-有些小技巧的更多相关文章

  1. 九度OJ 1001:A+B for Matrices

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:17682 解决:7079 题目描述: This time, you are supposed to find A+B where A and ...

  2. 九度oj 1001 A+B for Matrices 2011年浙江大学计算机及软件工程研究生机试真题

    题目1001:A+B for Matrices 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:15235 解决:6172 题目描述: This time, you are supposed ...

  3. 九度OJ 1534 数组中第K小的数字 -- 二分查找

    题目地址:http://ac.jobdu.com/problem.php?pid=1534 题目描述: 给定两个整型数组A和B.我们将A和B中的元素两两相加可以得到数组C. 譬如A为[1,2],B为[ ...

  4. 【九度OJ】题目1474:矩阵幂 解题报告

    [九度OJ]题目1474:矩阵幂 解题报告 标签(空格分隔): 九度OJ http://ac.jobdu.com/problem.php?pid=1474 题目描述: 给定一个n*n的矩阵,求该矩阵的 ...

  5. 【九度OJ】题目1193:矩阵转置 解题报告

    [九度OJ]题目1193:矩阵转置 解题报告 标签(空格分隔): 九度OJ http://ac.jobdu.com/problem.php?pid=1193 题目描述: 输入一个N*N的矩阵,将其转置 ...

  6. 【九度OJ】题目1191:矩阵最大值 解题报告

    [九度OJ]题目1191:矩阵最大值 解题报告 标签(空格分隔): 九度OJ http://ac.jobdu.com/problem.php?pid=1191 题目描述: 编写一个程序输入一个mXn的 ...

  7. 九度OJ 题目1384:二维数组中的查找

    /********************************* * 日期:2013-10-11 * 作者:SJF0115 * 题号: 九度OJ 题目1384:二维数组中的查找 * 来源:http ...

  8. 九度oj题目&amp;吉大考研11年机试题全解

    九度oj题目(吉大考研11年机试题全解) 吉大考研机试2011年题目: 题目一(jobdu1105:字符串的反码).    http://ac.jobdu.com/problem.php?pid=11 ...

  9. 【九度OJ】题目1069:查找学生信息 解题报告

    [九度OJ]题目1069:查找学生信息 解题报告 标签(空格分隔): 九度OJ [LeetCode] http://ac.jobdu.com/problem.php?pid=1069 题目描述: 输入 ...

  10. 【九度OJ】题目1174:查找第K小数 解题报告

    [九度OJ]题目1174:查找第K小数 解题报告 标签(空格分隔): 九度OJ 原题地址:http://ac.jobdu.com/problem.php?pid=1174 题目描述: 查找一个数组的第 ...

随机推荐

  1. Hadoop---日志服务器

    Hadoop---日志服务器 1.历史服务器: 启动: 1)测试使用: 1.做一个任务: 2.接受任务: 3.执行任务: 4.执行任务完成: 2)日志文件产生: 成功后:   失败后: 点击进入His ...

  2. nginx 隐藏 index.php 和 开启 pathinfo 模式的配置

    nginx 通过 location 的规则匹配将 php 转发给 php-fpm 处理后获取结果然后返回给客户端,转发模式可以通过 unix sock 或 tcp socket 方式.百度了好多文章我 ...

  3. 在Vue中关闭Eslint 的方法

    在vue项目中关闭ESLint方法:找到 webpack.base.conf.js 将这些代码注释掉, { test: /\.(js|vue)$/, loader: 'eslint-loader', ...

  4. ubuntu下的网速限制软件wondershaper (2011-09-18 00:00:00)转载▼

    上网或下载的时候我们常常希望网速快一点,但有时我们也需要限制网速,在ubuntu系统下,可以使用wondershaper,不仅可以限制下载速度还可以限制上传速度. 安装好之后,需要使用终端取得管理员权 ...

  5. day039 数据库索引

    今日内容: 1.为什么要有索引 简而言之,索引出现的意义是为了更方便,更快速的查询数据. 什么是索引 索引在mysql中也叫''键''或'key'(primary key unique key,ind ...

  6. Neo4J 教程

    好文转载: W3C: https://www.w3cschool.cn/neo4j/neo4j_cypher_api_example.html neo4j图数据库入门: http://blog.csd ...

  7. json解析写入mysql

    import json,requests,pymysql from pprint import pprint from datetime import datetime dt=datetime.now ...

  8. 安装ubuntu gnome桌面

    注意: ubuntu 14.04.5默认的为unity桌面,有多点触发,没有自带Tweak Tool工具. 安装gnome桌面 sudo apt-get install ubuntu-gnome-de ...

  9. python笔记4-if..elif-else条件语句

    python中条件判断使用if else来判断,多分支的话使用if elif ... else,也就是如果怎么怎么样就怎么怎么样,否则就怎么怎么这样,格式如下: #if是布尔类型判断,1个是真1个是假 ...

  10. DevExpress v18.1新版亮点——Reporting篇(二)

    用户界面套包DevExpress v18.1日前终于正式发布,本站将以连载的形式为大家介绍各版本新增内容.本文将介绍了DevExpress Reporting v18.1 的新功能,快来下载试用新版本 ...