A - {A} + {B}
Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Submit
Status
Description
给你两个集合,要求{A} + {B}.
注:同一个集合中不会有两个相同的元素.
Input
每组输入数据分为三行,第一行有两个数字n,m(0<n,m<=10000),分别表示集合A和集合B的元素个数.后两行分别表示集合A和集合B.每个元素为不超出int范围的整数,每个元素之间有一个空格隔开.
Output
针对每组数据输出一行数据,表示合并后的集合,要求从小到大输出,每个元素之间有一个空格隔开.
Sample Input
1 2
1
2 3
1 2
1
1 2
Sample Output
1 2 3
Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Submit
Status
Description
给你两个集合,要求{A} + {B}.
注:同一个集合中不会有两个相同的元素.
Input
每组输入数据分为三行,第一行有两个数字n,m(0<n,m<=10000),分别表示集合A和集合B的元素个数.后两行分别表示集合A和集合B.每个元素为不超出int范围的整数,每个元素之间有一个空格隔开.
Output
针对每组数据输出一行数据,表示合并后的集合,要求从小到大输出,每个元素之间有一个空格隔开.
Sample Input
1 2
1
2 3
1 2
1
1 2
Sample Output
1 2 3
1 2
#include<cstdio>
#include<map>
using namespace std;
int main()
{
int n, m;
while (scanf("%d%d", &n, &m) != EOF)
{
map<int, int> mp;
for (int i = 0; i < (m + n); i++)
{
int temp;
scanf("%d", &temp);
mp[temp]++;
}
map<int, int>::iterator b = mp.begin();
map<int, int>::iterator e = mp.end();
for (; b != e; )
{
printf("%d",b->first);
++b;
if (b == e)
printf("\n");
else
printf(" ");
}
}
}