人见人爱A-B hd 2034
来源:互联网 发布:淘宝项目 编辑:程序博客网 时间:2024/04/27 14:53
Problem Description
参加过上个月月赛的同学一定还记得其中的一个最简单的题目,就是{A}+{B},那个题目求的是两个集合的并集,今天我们这个A-B求的是两个集合的差,就是做集合的减法运算。(当然,大家都知道集合的定义,就是同一个集合中不会有两个相同的元素,这里还是提醒大家一下)
呵呵,很简单吧?
Input
每组输入数据占1行,每行数据的开始是2个整数n(0<=n<=100)和m(0<=m<=100),分别表示集合A和集合B的元素个数,然后紧跟着n+m个元素,前面n个元素属于集合A,其余的属于集合B. 每个元素为不超出int范围的整数,元素之间有一个空格隔开.
如果n=0并且m=0表示输入的结束,不做处理。
Output
针对每组数据输出一行数据,表示A-B的结果,如果结果为空集合,则输出“NULL”,否则从小到大输出结果,为了简化问题,每个元素后面跟一个空格.
Sample Input
3 3 1 2 3 1 4 7
3 7 2 5 8 2 3 4 5 6 7 8
0 0
Sample Output
2 3
NULL
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int main(){int a,b,i,j,h,k;int d[100];int c[100];int f[100];while(scanf("%d%d",&a,&b)!=EOF){if(a==0&&b==0)break;h=0;memset(f,-1,sizeof(f));for(i=0;i<a;i++)scanf("%d",&c[i]);for(i=0;i<b;i++)scanf("%d",&d[i]);for(i=0;i<a;i++){k=0;for(j=0;j<b;j++)if(c[i]!=d[j]){k++;}if(k==b){f[i]=c[i];h++;}}sort(f,f+a);if(h==0)printf("NULL\n");else{for(i=0;i<a;i++){if(f[i]>-1){printf("%d ",f[i]);}}printf("\n");}}}
0 0
- hd 2034 人见人爱A-B
- HD 2034 人见人爱A-B
- 人见人爱A-B hd 2034
- 人见人爱A+B hd 2033
- 人见人爱A^B hd 2035
- 1407301132-hd-人见人爱A+B.cpp
- 1407311042-hd-人见人爱A-B.cpp
- 1407311104-hd-人见人爱A^B.cpp
- hd 1093a+b
- hd 1094 a+b
- hd 1095 a+b
- HD 2075 a|b?
- hd 1412 {A} + {B}
- 1412201333-hd-A + B
- 【HD水】A+B
- hd 1720 A+B Coming
- hd 1229 还是A+B
- hd 2524 矩形A + B
- 网络直播内容审核:拒绝黄拒绝赌拒绝黄赌毒!
- string十大热点
- VB操作EXCEL
- hdoj4883TIANKENG’s restaurant
- 萌妹网红陪看球,欧洲杯直播技术探秘
- 人见人爱A-B hd 2034
- HDU5744 Keep On Movin
- LightOJ 1243 Guardian Knights 费用流
- 如何架构大规模云端直播录制集群?
- [李景山php]每天laravel-20160925|Pipeline.php
- POJ1328Radar Installation
- Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exc
- 手游直播到底难在哪里?
- 杭电ACM 2031,2057 进制转化问题