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. linux杀掉某个进程的脚本

    https://www.cnblogs.com/zeng1994/p/13a2c5a28e55dd3abc2c75a4fb80371a.html awk的说明: https://www.cnblogs ...

  2. 2 Button

    // <summary> /// 设置透明按钮样式 /// </summary> private void SetBtnStyle(Button btn) { btn.Flat ...

  3. hdu 5179 beautiful number

    beautiful number 问题描述 令 A = \sum_{i=1}^{n}a_i * {10}^{n-i}(1\leq a_i \leq 9)A=∑​i=1​n​​a​i​​∗10​n−i​ ...

  4. Huawei-R&S-网络工程师实验笔记20190530-FTP上传下载、STelnet登录、SFTP登录

    >Huawei-R&S-网络工程师实验笔记20190530-FTP上传下载.STelnet登录.SFTP登录 >>实验开始,参考<Huawei-R&S-网络工程 ...

  5. hdu2006 求奇数的乘积【C++】

    求奇数的乘积 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Subm ...

  6. Vue项目搭建及原理四

    四.Vue-cli工作原理及Vue实例创建,工作原理 (一)Vue-cli原理 1.webpack其实使用了node.js的express网页服务器来进行处理网页相关的数据,相当于使用一个类似apac ...

  7. spring配置Converter、Formatter日期转换器

    最近有点恶补spring的嫌疑,然后学了一点知识点纪录在此. 往往在项目中我们会遇到前端页面输入一个日期类型的字符串传递到后端后我们需要去做转换.甚至在传递的过程中就会报错. Spring有一个一劳永 ...

  8. Android第三方开源下拉框:NiceSpinner

     Android第三方开源下拉框:NiceSpinner Android原生的下拉框Spinner基本上可以满足Android开发对于下拉选项的设计需求,但现在越来越流行的下拉框不满足于Andro ...

  9. [国家集训队2012]tree(陈立杰)

    [国家集训队2012]tree(陈立杰) 题目 给你一个无向带权连通图,每条边是黑色或白色.让你求一棵最小权的恰好有need条白色边的生成树.题目保证有解. INPUT 第一行V,E,need分别表示 ...

  10. nyoj_212_K尾相等数_210402272239

    K尾相等数 时间限制:3000 ms  |  内存限制:65535 KB 难度:1   描述 输入一个自然数K(K>1),如果存在自然数M和N(M>N),使得K^M和K^N均大于等于100 ...