hdoj-1412-{A} + {B}
来源:互联网 发布:韩国扫二维码软件 编辑:程序博客网 时间:2024/06/08 10:44
Problem Description
给你两个集合,要求{A} + {B}.
注:同一个集合中不会有两个相同的元素.
注:同一个集合中不会有两个相同的元素.
Input
每组输入数据分为三行,第一行有两个数字n,m(0<n,m<=10000),分别表示集合A和集合B的元素个数.后两行分别表示集合A和集合B.每个元素为不超出int范围的整数,每个元素之间有一个空格隔开.
Output
针对每组数据输出一行数据,表示合并后的集合,要求从小到大输出,每个元素之间有一个空格隔开.
Sample Input
1 212 31 211 2
Sample Output
1 2 3
sb题一个, set的基础运用
#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#include<set>using namespace std;set<int>s;int main(){ int n,m; int a[20005],b[20005]; while(scanf("%d%d",&n,&m)!=EOF) { s.clear(); int w=0; for(int i=0;i<n;i++) scanf("%d",&a[i]); for(int i=n;i<m+n;i++) scanf("%d",&a[i]); for(int i=0;i<m+n;i++) { int t=a[i]; if(!s.count(t)) { b[w++]=t; s.insert(t); } } sort(b,b+w); for(int i=0;i<w-1;i++) printf("%d ",b[i]); printf("%d\n",b[w-1]); } return 0;}
0 0
- hdoj 1412 {A} + {B}
- hdoj 1412 {A} + {B}
- HDOJ 1412 {A} + {B}
- hdoj-1412-{A} + {B}
- HDOJ 1412 {A} + {B}
- hdoj.1412 {A} + {B} 20140724
- HDOJ 1412 {A} + {B}解题报告
- HDOJ(HDU).1412 {A} + {B} (STL SET)
- A+B(HDOJ)
- HDOJ-1228-A+B
- HDOJ A+B Problem
- hdoj 1228 A + B
- HDoj-1228-A + B
- HDOJ 1576 A/B
- hdoj A + B Again
- hdoj 2101 a+b
- hdoj 2705 A|B?
- HDOJ 1228 A + B
- Babel 6.0 全新特性解析
- 适配器模式(Adapter)
- MySQL入门——插入记录时不指定的字段就赋默认值
- GDOI2016回文树
- Java的线程常用方法
- hdoj-1412-{A} + {B}
- 坑爹的一天——关于配置samba服务器(1)
- 大数阶乘
- CentOS(5.8/6.4)linux生产环境若干优化实战
- C#理解Thread.Sleep方法(2)
- BFS 走迷宫 与STL的低效
- poj 2369 Permutations(置换)
- struts学习笔记
- Mac下MySQL卸载方法