Description

给出N个数,要求把其中重复的去掉,只保留第一次出现的数。
例如,给出的数为1 2 18 3 3 19 2 3 6 5 4,其中2和3有重复,去除后的结果为1 2 18 3 19 6 5 4。

Input

输入第一行为正整数T,表示有T组数据。
接下来每组数据包括两行,第一行为正整数N,表示有N个数。第二行为要去重的N个正整数。

Output

对于每组数据,输出一行,为去重后剩下的数字,数字之间用一个空格隔开。

Sample Input

2
11
1 2 18 3 3 19 2 3 6 5 4
6
1 2 3 4 5 6

Sample Output

1 2 18 3 19 6 5 4
1 2 3 4 5 6

HINT

对于30%的数据,1 <= N <= 100,给出的数不大于100,均为非负整数;

对于50%的数据,1 <= N <= 10000,给出的数不大于10000,均为非负整数;

对于100%的数据,1 <= N <= 50000,给出的数在32位有符号整数范围内。

提示:

由于数据量很大,使用C++的同学请使用scanf和printf来进行输入输出操作,以免浪费不必要的时间。

Solution

实在不想做这个题就从网上随便粘了一篇交上去了=v=

Code

 #include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>
#define ll long long
using namespace std;
const int MAXN = + ;
int read()
{
int x = , f = ; char ch = getchar();
while(ch < '' || ch > ''){if(ch == '-') f *= -; ch = getchar();}
while(ch >= '' && ch <= ''){x = x * + ch - ''; ch = getchar();}
return x * f;
}
map<int, int> st;
int N, x;
int main()
{
int T = read();
while(T--)
{
N = read();
st.clear();
bool flag = true;
for(int i=; i<N; i++)
{
x = read();
if(st[x] == )
{
if(!flag) printf(" ");
printf("%d", x);
flag = false;
}
st[x] = ;
}
printf("\n");
}
return ;
}

最新文章

  1. IIS7+windows 64位配置注意事项
  2. hdu---1024Max Sum Plus Plus(动态规划)
  3. java中文件操作
  4. 获取DLL的文件路径以及调用DLL的文件路径
  5. [React Testing] Intro to Shallow Rendering
  6. iOS:UI系列之UIScrollview和UIPagecontrol
  7. poj 2010 Moo University - Financial Aid (贪心+线段树)
  8. FZU 1502 Letter Deletion
  9. css优先级之特殊性
  10. Not supported by Zabbix Agent &amp; zabbix agent重装
  11. 【C#学习笔记之一】C#中的关键字
  12. JSP基础使用
  13. Beta Scrum Day 3
  14. 从PRISM开始学WPF(六)MVVM(二)Command?
  15. windows与linux的文件夹共享
  16. 语音识别传统方法(GMM+HMM+NGRAM)概述
  17. 2017-2018-2 20155314《网络对抗技术》Exp4 恶意代码分析
  18. daal4py 随机森林模型训练mnist并保存模型给C++ daal predict使用
  19. Git Windows客户端保存用户名和密码
  20. .Net Core MVC实现自己的AllowAnonymous

热门文章

  1. SQL Server 获取(本周、本月、本旬、本季、本年)的某一天
  2. 撩课-Web大前端每天5道面试题-Day15
  3. 图解 CMS 垃圾回收机制,你值得拥有(转 强烈推荐)
  4. springcloud 集成kafka问题记录,发消息报错:ERROR o.s.kafka.support.LoggingProducerListener - Exception thrown when sending a message with key=&#39;null&#39; and payload=&#39;{-1,
  5. 移动端App开发 - 02 - iPhone/iPad/Android UI尺寸规范
  6. mac下安装elasticsearch报错Exception BindTransportException[Failed to bind to [9300-9400]]
  7. git 和github
  8. 进程间通信——队列和管道(multiprocess.Queue、multiprocess.Pipe)
  9. time random sys 模块
  10. [翻译] PQFCustomLoaders