hdu 2034 人见人爱A-B
题目连接
http://acm.hdu.edu.cn/showproblem.php?pid=2034
人见人爱A-B
Description
参加过上个月月赛的同学一定还记得其中的一个最简单的题目,就是{A}+{B},那个题目求的是两个集合的并集,今天我们这个A-B求的是两个集合的差,就是做集合的减法运算。(当然,大家都知道集合的定义,就是同一个集合中不会有两个相同的元素,这里还是提醒大家一下)
呵呵,很简单吧?
Input
如果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
Sample Output
2 3 
NULL
stl大法好。。
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<set>
using std::set;
using std::min;
using std::find;
using std::pair;
using std::vector;
using std::multiset;
#define pb(e) push_back(e)
#define sz(c) (int)(c).size()
#define mp(a, b) make_pair(a, b)
#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cls(arr, val) memset(arr, val, sizeof(arr))
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define tr(c, i) for(iter(c) i = (c).begin(); i != (c).end(); ++i)
const int N = 1010;
const int INF = 0x3f3f3f3f;
set<int> A, B;
vector<int> res;
int main() {
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w+", stdout);
#endif
int a, b, v;
while(~scanf("%d %d", &a, &b), a + b) {
rep(i, a + b) {
scanf("%d", &v);
if(i < a) A.insert(v);
else B.insert(v);
}
for(set<int>::iterator i = A.begin(); i != A.end(); ++i) {
if(B.find(*i) == B.end()) res.pb(*i);
}
int n = sz(res);
if(!n) { puts("NULL"); continue; }
rep(i, n) printf("%d ", res[i]);
putchar('\n');
A.clear(), B.clear(), res.clear();
}
return 0;
}
hdu 2034 人见人爱A-B的更多相关文章
- hdu 2034人见人爱A-B
		
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2034 解题思路:set的基本用法 #include<iostream> #include& ...
 - HDU 2034 人见人爱A-B                                                    分类:            ACM             2015-06-23 23:42    9人阅读    评论(0)    收藏
		
人见人爱A-B Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Su ...
 - HDU 2034 人见人爱A-B【STL/set】
		
人见人爱A-B Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Sub ...
 - 杭电 2034 人见人爱A-B
		
http://acm.hdu.edu.cn/showproblem.php?pid=2034 人见人爱A-B Time Limit: 2000/1000 MS (Java/Others) Mem ...
 - hdu 2035 人见人爱A^B
		
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2035 人见人爱A^B Description 求A^B的最后三位数表示的整数.说明:A^B的含义是“A ...
 - HDU 2035 人见人爱A^B                                                    分类:            ACM             2015-06-22 23:54    9人阅读    评论(0)    收藏
		
人见人爱A^B Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Su ...
 - 杭电2034——人见人爱A-B
		
#include <stdio.h> #include <algorithm> using namespace std; int main () { int a[110],b[ ...
 - HDU 2033 人见人爱A+B
		
http://acm.hdu.edu.cn/showproblem.php?pid=2033 Problem Description HDOJ上面已经有10来道A+B的题目了,相信这些题目曾经是大家的 ...
 - HDU 2035.人见人爱A^B-快速幂
		
人见人爱A^B Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Sub ...
 
随机推荐
- 大陆地区OpenStack项目Core现状(截至2016年1月28日,转载自陈沙克日志)
			
陈沙克 经常有朋友问,大陆地区大概有多少位OpenStack项目的Core.这个问题,现在其实不太好回答,如果需要准确统计的话.下面仅仅是一个大概估计,有遗漏的,希望朋友指出,我来补全. 文档修改历史 ...
 - OSGI.NET mainfest.xml 配置
			
在使用 OSGI.NET进行插件式的开发时,需要对 Mainfest.xml 进行配置, Mainfest 文件是插件的重要配置文件,其中暴露了插件启动方式以及插件启动时所依赖的程序集或其它资源的信息 ...
 - 合并同一目录下多个EXCEL的多个sheet
			
合并同一目录下多个EXCEL的多个sheet到一个excel的一个sheet 1.把多个excel表都放在同一个文件夹里面,并在这个文件夹里面新建一个excel2.打开新建的excel表,并右键单击s ...
 - 关于玩QQ消息导入导出功能的感想!
			
今天玩了一下QQ的导入导出聊天记录的功能,感觉自己有些白痴,因为作为一个软件开发人员对自己平时使用的软件的功能掌握的不够,别说其他的任何东西了就连功能性的操作有些也不知道更别说熟练或精通了,这不是一个 ...
 - No.009 Palindrome Number
			
9. Palindrome Number Total Accepted: 136330 Total Submissions: 418995 Difficulty: Easy Determine whe ...
 - web.config中sessionState节点的配置方案
			
web.config中sessionState节点的配置方案 web.config关于sessionState节点的配置方案,sessionState有五种模式:Custom,off,inProc,S ...
 - linux 内核(驱动)常用函数
			
2.4.1 内存申请和释放 include/linux/kernel.h里声明了kmalloc()和kfree().用于在内核模式下申请和释放内存. void *kmalloc(unsigned ...
 - Hbase多master
			
单台master的配置 hbase.master master:60000 这是我们通常配置的,这样就定义了master是的ip和端口. 但是当我们需要配置多台master进行,我们只需要提供端口,因 ...
 - hdu1505
			
the main algorithm as the 1506 #include <stdio.h> #include <iostream> #include <strin ...
 - MYSQL将表名称修改成大写的存储过程
			
1. 条件: 1.1 Mysql设置对大小写敏感 2. 执行下述存储过程: #call uppercase('库名') DROP PROCEDURE IF EXISTS uppercase; )) B ...