NYOJ intersection set
来源:互联网 发布:淘宝账号无限注册 编辑:程序博客网 时间:2024/06/08 05:39
intersection set
时间限制:1000 ms | 内存限制:65535 KB
难度:1
- 描述
- 两个集合,你只需要求出两个集合的相同元素,并输出个数。
- 输入
- m n
{a1 , a2 , a3 , a4 ... ai ... am}
{b1 , b2 , b3 , b4 ... bi ... bn}
1 <= n , m <= 50000 , 保证一个集合中不会输入重复数据
0 <= ai , bi <= 100000
多组测试数据 - 输出
- 一行一个数据,为两个集合中相同的元素个数
- 样例输入
8 81 5 6 9 10 12 16 595 6 9 8 15 17 65 98
- 样例输出
3
#include<cstdio>#include<cstdlib>#include<cstring>using namespace std;const int max=100005;int a[max];int main(){int i,j,ans,m,n,s;while(scanf("%d%d",&m,&n)!=EOF){memset(a,0,sizeof(a));for(i=0;i<m;++i){scanf("%d",&s);a[s]=1;}ans=0;for(i=0;i<n;++i){scanf("%d",&s);if(a[s]==1)ans++;}printf("%d\n",ans);}return 0;}
0 0
- nyoj-626-intersection set
- nyoj 643intersection set
- NYOJ intersection set
- intersection set
- intersection set
- intersection set
- intersection set
- NYOJ626 intersection set
- 626 intersection set
- 【Lua】ElJudge 002 Set Intersection
- set intersection问题求解(python版)
- EI judge 002 Set Intersection 算法题解
- 349. Intersection of Two Arrays (set)
- Intersection
- Intersection
- Intersection
- Intersection
- LeetCode 349. Intersection of Two Arrays 350. Intersection of Two Arrays II set map使用 ****
- 检测Xpath版本
- c语言递归算法--深入浅出(1)
- 资源供给:IO子系统之一
- wallpaperTravelToScreenWidthRatio 函数分析
- C++ 类和数据抽象
- NYOJ intersection set
- 《算法导论》笔记(4)堆排序与快速排序 含部分习题
- 利用 spring+freemarker 发送邮件
- .Net Mvc validateRequest设置为false不起作用的解决方案
- MATLAB数字图像处理从入门到精通(持续更新)
- 尽力而为还不够
- poj 3083 dfs
- SQL中Group By的使用
- 自定义数据库 -- ContentProvider和ContentResolver