码迷,mamicode.com
首页 > 其他好文 > 详细

BZOJ 2761 不重复数字 (Hash)

时间:2014-07-17 10:02:58      阅读:231      评论:0      收藏:0      [点我收藏+]

标签:style   使用   io   for   re   c   

题解:直接使用STL中的hash去重即可

#include <cstdio>
#include <map>
using namespace std;
int ans[50010];
int main(){
    int T,n,tmp;
    scanf("%d",&T);
    while(T--){
        int cnt=0; map<int,int>m;
        scanf("%d",&n);
        for(int i=0;i<n;i++){
            scanf("%d",&tmp);
            if(!m[tmp])ans[cnt++]=tmp,m[tmp]=1;
        }
        for(int i=0;i<cnt-1;i++)printf("%d ",ans[i]);
        printf("%d\n",ans[cnt-1]);
    }
    return 0;
}

BZOJ 2761 不重复数字 (Hash),布布扣,bubuko.com

BZOJ 2761 不重复数字 (Hash)

标签:style   使用   io   for   re   c   

原文地址:http://www.cnblogs.com/forever97/p/bzoj2761.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!