bzoj 2761: [JLOI2011]不重复数字【hash】
map会T,双hash会冲突……于是非酋写了个三hash
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=1000005,mod1=739391,mod2=967543,mod3=1000003;
int T,n;
bool h1[N],h2[N],h3[N];
int read()
{
int r=0,f=1;
char p=getchar();
while(p>'9'||p<'0')
{
if(p=='-')
f=-1;
p=getchar();
}
while(p>='0'&&p<='9')
{
r=r*10+p-48;
p=getchar();
}
return r*f;
}
int main()
{
T=read();
while(T--)
{
n=read();
memset(h1,0,sizeof(h1));
memset(h2,0,sizeof(h2));
memset(h3,0,sizeof(h3));
for(int i=1;i<=n;i++)
{
int x=read(),x1=(x%mod1+mod1)%mod1,x2=(x%mod2+mod2)%mod2,x3=(x%mod3+mod3)%mod3;
if(!h1[x1]||!h2[x2]||!h3[x3])
{
h1[x1]=1,h2[x2]=1,h3[x3]=1;
printf("%d ",x);
}
}
puts("");
}
return 0;
}
bzoj 2761: [JLOI2011]不重复数字【hash】的更多相关文章
- BZOJ 2761: [JLOI2011]不重复数字 hash哈希
题目就不贴了 点我看题 题意:这题题意很简明,就是给一个序列,把序列里相同的删掉,然后输出,按原数列顺序. 思路:这题之前QZZ和ZN大神犇叫我去做,辣时还不会hash,就留着了.最近某夏令营学会了h ...
- BZOJ 2761: [JLOI2011]不重复数字 水题
2761: [JLOI2011]不重复数字 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 2100 Solved: 809 题目连接 http:// ...
- bzoj 2761 [JLOI2011]不重复数字(哈希表)
2761: [JLOI2011]不重复数字 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 3210 Solved: 1186[Submit][Sta ...
- BZOJ 2761: [JLOI2011]不重复数字 set
Description 给出N个数,要求把其中重复的去掉,只保留第一次出现的数. 例如,给出的数为1 2 18 3 3 19 2 3 6 5 4,其中2和3有重复,去除后的结果为1 2 18 3 19 ...
- bzoj 2761: [JLOI2011]不重复数字 (map||Treap)
链接:https://www.lydsy.com/JudgeOnline/problem.php?id=2761 思路: map标记 实现代码: #include<bits/stdc++.h&g ...
- bzoj 2761: [JLOI2011]不重复数字
#include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #d ...
- 2761: [JLOI2011]不重复数字(平衡树)
2761: [JLOI2011]不重复数字 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 2133 Solved: 825[Submit][Stat ...
- 2761: [JLOI2011]不重复数字(哈希表)
2761: [JLOI2011]不重复数字 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 1770 Solved: 675[Submit][Stat ...
- 【BZOJ】2761: [JLOI2011]不重复数字(set+巨水题+超坑题)
http://www.lydsy.com/JudgeOnline/problem.php?id=2761 太水了,不说了. 但是这格式错误我已经没话说了....行末不能有空格 #include < ...
随机推荐
- weex 项目开发(三) weexpack + weex-ui
github地址:weex-ui https://github.com/alibaba/weex-ui 官网: https://alibaba.github.io/weex-ui/#/cn/ 创建项目 ...
- android-problem——remount of /system failed: Read-only file system
adb remount后仍旧不能对system进行读写.需要进行adb disable-verity 在Android6.0 (Android M)userdebug版本上(eng版本不存在该问题), ...
- oracle user locke
1:管理员登录 sqlplus sys/pwd as sysdba sql->alter user jd account unlock; commit; SQL> password new ...
- 面向接口的webservice发布方式
import javax.jws.WebService; /**面向接口的webservice发布方式 */ @WebService public interface JobService { pub ...
- 嵌入式开发之davinci--- 8148/8168/8127 中的添加算饭scd 场景检测 代码实现
http://blog.csdn.net/mianhuantang848989/article/details/38035731 http://www.61ic.com/Article/DaVinci ...
- html-基本form元素---ShinePans
<html> <meta http-equiv="content-type" content="text/html;charset=UTF-8" ...
- Windows 8实用窍门系列:20.Windows 8中的GridView使用(二)和DataTemplateSelector
在本文中所讲述内容的实例仍然沿用于上篇文章,有什么疑惑可以参考上篇文章. 一 GroupStyle 在GridView控件中我们可以对数据进行分组显示,通过对GridView的GroupStyle进行 ...
- Python 001- 将URL中的汉字转换为url编码
很多时候想爬取网页信息,结果出现URL是中文的情况(比如‘耳机'),url的地址编码却是%E8%80%B3%E6%9C%BA,因此需要做一个转换.这里我们就用到了模块urllib. 代码超简单 #-* ...
- 状态模式-State
状态模式:当一个对象的内在状态改变时允许改变其行为,这个对象看起来像是改变了其类. 状态模式结构图: 代码实现:
- 浏览器上的Qt Quick
你想不想在浏览器上运行你的Qt Quick程序呢?在Qt 5.12之前,唯一的方法是使用Qt WebGL Streaming技术把界面镜像到浏览器上.但该方法有不少缺陷,下文会说.前不久随着Qt 5. ...