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. SetACL 使用方法详细参数中文解析

    示例: SetACL.exe c:\nihao /dir /deny everyone /read_ex 设置E:\wxDesktop 文件夹 everyone 用户为读取和运行权限 SetACL M ...

  2. CDR如何使用钢笔工具进行完美抠图?【6·18特惠倒计时!】

    不要以为抠图只能在图像处理软件中实现,矢量图形绘制软件CorelDRAW一样可以,而且方法很多,文章介绍使用CDR钢笔工具抠图的方法. 提示说明: 首先说明一下,CDR中的钢笔工具和其他平面设计软件中 ...

  3. cocos creator游戏适配这事

    在想cocos适配之前,我们想想网页是怎么适配的.浏览器有各种规格,网页的一般做法是:背景图片铺满,网页内容保持在背景图片上居中,就实现了适应或者适配.css一般这样: .bg{ height:582 ...

  4. HTML5轻松实现全屏视频背景

    想在你的网页首页中全屏播放一段视频吗?而这段视频是作为网页的背景,不影响网页内容的正常浏览.那么我告诉你有一款Javascript库正合你意,它就是Bideo.js. 参考网址: https://ww ...

  5. 【Apache Kafka】一、Kafka简介及其基本原理

      对于大数据,我们要考虑的问题有很多,首先海量数据如何收集(如Flume),然后对于收集到的数据如何存储(典型的分布式文件系统HDFS.分布式数据库HBase.NoSQL数据库Redis),其次存储 ...

  6. 学生成绩管理系统C(链表)语言

    #include"stdio.h" #include"stdlib.h" #include"string.h" //用于调用一些函数 str ...

  7. Linux:用户和组总结

    从创建文件说起:useradd xiaomi           这里是创建了xiaomi用户 默认系统还会创建:/home/xiaomi  /var/mail/xiaomi        即家目录和 ...

  8. 终端打印SQL语句

    在 Django 项目的 settings.py 文件中配置: LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'handle ...

  9. win10下VMware Workstation 14运行虚拟机黑屏

    最新 升级电脑Win10自动升级后,在打开虚拟机后,很卡,且出现黑屏,但是挂起后仍能显示锁屏界面,网上就一顿搜.下面放解决方法. 管理员运行 netsh winsock reset 帮你解决一切烦恼. ...

  10. Pyhon信息采集 - 喜马拉雅专辑歌曲

    目录 Pyhon信息采集 - 喜马拉雅专辑歌曲 Pyhon信息采集 - 喜马拉雅专辑歌曲 setting.py # 喜马拉雅URL XMLY_URL = "https://www.ximal ...