题目
题目链接
题解实现题。
用map实现,因为集合中的值太大做不了数组索引,因此用map。
因为要求差集就还要单独存一下a中的元素,用的vector。
代码#include
using namespace std;
int n, s, m, num, ans[2010];
map cnt;
vector a;
int main()
{
cin>>n;
for(int i = 1;i >s, cnt[s] ++, a.push_back(s);
cin>>m;
for(int i = 1;i >s, cnt[s] ++;
for(map::iterator it = cnt.begin();it != cnt.end();it ++)
if(it->second == 2) ans[num++] = it->first;
sort(ans, ans+num);
for(int i = 0;i
关注
打赏