http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2719

 #include <stdio.h>
#include <string.h>
const int N=;
using namespace std;
int a[N],b[N],f[N];
int main()
{
int n1,n2,m,o=;
while(~scanf("%d %d %d",&n1,&n2,&m))
{
o++;
int flag1 = ,flag2 = ;
if (n1==&&n2==&&m==)
break;
memset(a,-,sizeof(a));
memset(b,-,sizeof(b));
for (int i = ; i < m; i++)
scanf("%d",&f[i]);
int t1,t2,tt;
for (int i = ; i < m; i++)
{
tt = f[i];
while()
{
t1 = tt%n1;
if (a[t1]==-)
{
a[t1] = tt;
flag1 = ;
break;
}
else
{
int temp = a[t1];
a[t1] = tt;
t2 = temp%n2;
if (b[t2]==-)
{
b[t2] = temp;
flag2 = ;
break;
}
else
{ tt = b[t2];
b[t2] = temp;
flag2 = ; }
}
} }
printf("Case %d:\n",o);
if (flag1)
{
printf("Table 1\n");
for (int i = ; i < n1; i++)
{
if (a[i]!=-)
printf("%d:%d\n",i,a[i]); }
}
if (flag2)
{
printf("Table 2\n");
for (int i = ; i < n2; i++)
{
if (b[i]!=-)
printf("%d:%d\n",i,b[i]);
}
} }
return ;
}

Cuckoo for Hashing的更多相关文章

  1. Cuckoo for Hashing(hash)hunnuoj

    Problem B:Cuckoo for HashingAn integer hash table is a data structure that supports insert, delete a ...

  2. 中国海洋大学第四届朗讯杯高级组 I Cuckoo for Hashing

    http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2719&cid=1203 题意 :意思就是哈希来的,具体大意就是说有两个哈希表,然后有这样 ...

  3. HNU 13064 Cuckoo for Hashing解题报告 North America - East Central 2013

    题目大意:使用两个哈希表来解决哈希冲突的问题.假如现在有两个哈希表分别为:H1,H2 ,大小分别为:n1,n2:现有一数据X需要插入,其插入方法为: 1.计算index1 = X MOD N1,  若 ...

  4. Cuckoo for Hashing_双哈希表

    问题 B: Cuckoo for Hashing 时间限制: 1 Sec  内存限制: 64 MB提交: 24  解决: 12[提交][状态][讨论版] 题目描述 An integer hash ta ...

  5. 2014 UESTC 暑前集训队内赛(2) 部分解题报告

    B.Cuckoo for Hashing 模拟题. 代码: #include <iostream> #include <cstdio> #include <cstring ...

  6. HDU 1672 Cuckoo Hashing

    Cuckoo Hashing Description One of the most fundamental data structure problems is the dictionary pro ...

  7. BloomFilter 与 Cuckoo Filter

    BloomFilter 与 CuckooFilter Bloom Filter 原理 Bloom Filter是一种空间效率很高的随机数据结构,它的原理是,当一个元素被加入集合时,通过K个相互独立的H ...

  8. Cuckoo hash算法分析——其根本思想和bloom filter一致 增加hash函数来解决碰撞 节省了空间但代价是查找次数增加

    基本思想: cuckoo hash是一种解决hash冲突的方法,其目的是使用简单的hash 函数来提高hash table的利用率,同时保证O(1)的查询时间 基本思想是使用2个hash函数来处理碰撞 ...

  9. Locality-sensitive hashing Pr[m(Si) = m(Sj )] = E[JSˆ (Si, Sj )] = JS(Si, Sj )

    A hash function that maps names to integers from 0 to 15. There is a collision between keys "Jo ...

随机推荐

  1. POJ 3070 - 快速矩阵幂求斐波纳契数列

    这题并不复杂. 设$A=\begin{pmatrix} 1 & 1 \\ 1 & 0 \end{pmatrix}$ 由题中公式: $\begin{pmatrix}f(n+1) & ...

  2. spring+spring MVC+mybatis 框架搭建

    1.新建一个javaWeb工程Test,创建时记得勾选web.xml文件. 2.导入需要的jar包,Mybatis所有的jar,spring所有的jar,mysql驱动包. 这里mybatis和spr ...

  3. HDU_5723_最小生成树+任意两点距离的期望

    Abandoned country Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others ...

  4. Git学习总结一(下载、初始化、添加文件)

    Git下载地址 安装完成后,还需要最后一步设置,在命令行输入: $ git config --global user.name "Your Name" $ git config - ...

  5. vue中使用Swiper

    第一步:安装swiper在项目目录下打开命令窗口输入命令:npm install swiper 第二步:引入js文件 第三步:引入css文件在main.js文件中引入css文件

  6. 使用python的几个小经验(查看文档)

    好久没有水博客了,未来再过20天不到的时间又得参加软考,今天终于得好好水一发帖子 关于Python,很多人包括我之前都不知道怎么找文档,现在有一个好办法,就是在命令行模式下调用pydoc –p xxx ...

  7. IO相关操作

    IO相关操作 对于IO操作而言,有四个基本的操作:open .read .write .close 我们来逐个解释.    在此之前我们先解释一下什么是文件描述符 文件描述符 操作系统通过一个整数开代 ...

  8. dubbo服务telnet命令的使用

    转自:https://www.cnblogs.com/feiqihang/p/4387330.html dubbo服务发布之后,我们可以利用telnet命令进行调试.管理.Dubbo2.0.5以上版本 ...

  9. jdk8--十大新特性

    https://www.cnblogs.com/dennyzhangdd/p/6722445.html 一.十大特性 1.Lambda表达式 2.Stream函数式操作流元素集合 3.接口新增:默认方 ...

  10. 用Twebbrowser做可控编辑器与MSHTML(调用js)

    记得intraweb的网页设计也程序开发分开中,是怎么定义的变量的.就是在网页中插入占位符.我们规定占位符是{%Name%} {%Birthday%}单页面装载之前or之后,我们用自己的js查找占位符 ...