Kattis - CD
CD
Jack and Jill have decided to sell some of their Compact Discs, while they still have some value. They have decided to sell one of each of the CD titles that they both own. How many CDs can Jack and Jill sell?
Neither Jack nor Jill owns more than one copy of each CD.
Input
The input consists of a sequence of test cases. The first line of each test case contains two non-negative integersNN and MM, each at most one million, specifying the number of CDs owned by Jack and by Jill, respectively. This line is followed by NN lines listing the catalog numbers of the CDs owned by Jack in increasing order, and MMmore lines listing the catalog numbers of the CDs owned by Jill in increasing order. Each catalog number is a positive integer no greater than one billion. The input is terminated by a line containing two zeros. This last line is not a test case and should not be processed.
Output
For each test case, output a line containing one integer, the number of CDs that Jack and Jill both own.
| Sample Input 1 | Sample Output 1 |
|---|---|
3 3 |
2 |
题意
计算两个人的CD的序号有多少个相同的
代码
#include<bits/stdc++.h>
using namespace std;
#define LL long long
const int maxn = ;
LL n, m;
LL a[maxn];
int main() {
while(cin >> n >> m) {
if(n == m && n == )
break;
LL x, cnt = ;
memset(a, , sizeof(a));
for(LL i = ; i < n; i++) {
cin >> x;
a[x] = ;
}
for(LL i = ; i < m; i++) {
cin >> x;
if(a[x])
cnt++;
}
cout << cnt << endl;
}
}
Kattis - CD的更多相关文章
- linux常用命令(1)cd命令
1 命令格式:cd [目录名]2 命令功能切换当前目录至dirName3 常用范例3.1 进入系统根目录cd /3.2 进入上级目录cd .. 或者 cd ..//3.3 进入当前用户主目录当前用 ...
- CI Weekly #8 | CI/CD 技能进阶路线
在使用 flow.ci 进行持续集成的过程中,也许你会遇到一些小麻烦.最近我们整理了一些常见问题在 flow.ci 文档之 FAQ,希望对你有用.如果你遇到其他问题,也可以通过「在线消息」或去 Git ...
- CI Weekly #6 | 再谈 Docker / CI / CD 实践经验
CI Weekly 围绕『 软件工程效率提升』 进行一系列技术内容分享,包括国内外持续集成.持续交付,持续部署.自动化测试. DevOps 等实践教程.工具与资源,以及一些工程师文化相关的程序员 Ti ...
- 例解 Linux cd 命令
cd 命令是 *nix 系统中最基本的命令,它所做的事情是改变你当前所在的目录.本文详细介绍该命令,它所能完成的功能以及关于该命令内在的东西. cd 命令:一个内置命令 BASH Shell 是大多 ...
- 如何使用DOS命令(cd命令)
如何使用DOS命令 DOS是Disk Operation System(磁盘操作系统)的简称,是个人计算机上的一类操作系统.它直接操纵管理硬盘的文件,一般都是黑底白色文字的界面.顾名思义,DOS主要是 ...
- cd命令
[cd] 切换目录 cd===>change directory 命令功能 : 切换目录到dirname 命令实例: 实例1:切换到跟目录下 命令: cd / 输出: ...
- 轻量级Java EE企业应用实战(第4版):Struts 2+Spring 4+Hibernate整合开发(含CD光盘1张)
轻量级Java EE企业应用实战(第4版):Struts 2+Spring 4+Hibernate整合开发(含CD光盘1张)(国家级奖项获奖作品升级版,四版累计印刷27次发行量超10万册的轻量级Jav ...
- Linux命令学习总结:cd命令
命令简介: 该命令用来切换当前目录.cd 是change directory 的缩写 命令语法: cd [-L|-P] [dir] 使用示例 1:切换到当前目录的上一级目录 1: [root@DB-S ...
- 每天一个linux命令(2):cd命令
1. 命令格式: cd [目录名] 2. 命令功能: 切换当前目录至dirName 3. 常用范例 3.1 例一:进入系统根目录 命令: cd / 输出: [root@localhost ~]# cd ...
随机推荐
- Linux date命令的用法(转)
1.命令:date 2.命令功能:date 可以用来显示或设定系统的日期与时间. 3.命令参数 -d<字符串>:显示字符串所指的日期与时间.字符串前后必须加上双引号: -s<字符串& ...
- Codeforces Round #471 (Div. 2)A. Feed the cat
After waking up at hh:mm, Andrew realised that he had forgotten to feed his only cat for yet another ...
- sql2008删除语句.txt
delete from [aixinxing].[dbo].[bbs2] where announceID in (select AnnounceID from [aixinxing].[dbo].[ ...
- [luogu3232 HNOI2013] 游走 (高斯消元 期望)
传送门 题目描述 一个无向连通图,顶点从1编号到N,边从1编号到M. 小Z在该图上进行随机游走,初始时小Z在1号顶点,每一步小Z以相等的概率随机选 择当前顶点的某条边,沿着这条边走到下一个顶点,获得等 ...
- CSS3 创建简单的网页动画 – 实现弹跳球动
基础准备对于这个实现,我们需要一个简单的 div ,并且样式类名为 ball : HTML 代码: <div class="ball"></div> 我们将 ...
- 在使用SSH+JPA开发中,ajax使用ObjectMapper类从后台向前台传值
使用ObjectMapper对象的writeValue方法 ObjectMapper objectMapper = new ObjectMapper(); objectMapper.writeValu ...
- 全球级的分布式数据库 Google Spanner原理
开发四年只会写业务代码,分布式高并发都不会还做程序员?->>> Google Spanner简介 Spanner 是Google的全球级的分布式数据库 (Globally-Di ...
- rabbitMQ学习笔记(六) topic类型消息。
上一节中使用了消息路由,消费者可以选择性的接收消息. 但是这样还是不够灵活. 比如某个消费者要订阅娱乐新闻消息 . 包括新浪.网易.腾讯的娱乐新闻.那么消费者就需要绑定三次,分别绑定这三个网站的消息类 ...
- POJ 2191
只会打表 #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring ...
- 初识MVC之建项
MVC全名是Model View Controller,是模型(model)-视图(view)-控制器(controller)的缩写,用一种业务逻辑.数据.界面显示分离的方法组织代码,将业务逻辑聚集到 ...