[JLOI2011]不重复数字

题目大意:
  给你n个数,将它们去重后,按照第一个出现的顺序输出。

思路:
  本来应该用hash或者一些数据结构的,不过可以用STL水过。
  选这道题做是因为发现A掉的人很多,结果没想到是这么水。

 1 #include<cstdio>
 2 #include<cctype>
 3 #include<hash_set>
 4 inline int getint() {
 5     register char ch;
 6     register bool neg=false;
 7     while(!isdigit(ch=getchar())) if(ch=='-') neg=true;
 8     register int x=ch^'0';
 9     while(isdigit(ch=getchar())) x=(((x<<2)+x)<<1)+(ch^'0');
10     return neg?-x:x;
11 }
12 __gnu_cxx::hash_set<int> set;
13 int main() {
14     for(register int T=getint();T;T--) {
15         set.clear();
16         const int n=getint();
17         for(register int i=1;i<=n;i++) {
18             const int x=getint();
19             if(!set.count(x)) {
20                 if(i!=1) putchar(' ');
21                 printf("%d",x);
22                 set.insert(x);
23             }
24         }
25         putchar('
');
26     }
27     return 0;
28 }
原文地址:https://www.cnblogs.com/skylee03/p/8074104.html