【数据结构•hash表】OIBH模拟赛2002#1之集合
集合(oibh noip 2002模拟赛#1之第1题)
给定两个集合A、B,集合内的任一元素x满足1 ≤ x ≤ 10^9,并且每个集合的元素个数不大于10^5。我们希望求出A、B之间的关系。
任务:给定两个集合的描述,判断它们满足下列关系的哪一种:
A是B的一个真子集,输出“A is a proper subset of B”
B是A的一个真子集,输出“B is a proper subset of A”
A和B是同一个集合,输出“A equals B”
A和B的交集为空,输出“A and B are disjoint”
上述情况都不是,输出“I'm confused!”
Input
输入文件(SUBSET)有两行,分别表示两个集合,每行的第一个整数为这个集合的元素个数(至少一个),然后紧跟着这个集合的元素(均为不同的正整数)
Output
输出文件 ( SUBSET ) 只有一行,就是A、B的关系。
Sample Input
2 55 27 2 55 27
Sample Output
A equals B
Hint
附加样例
======================================
样例输入二:
3 9 24 1995
2 9 24
样例输出二:
B is a proper subset of A
======================================
样例输入三:
3 1 2 3
4 1 2 3 4
样例输出三:
A is a proper subset of B
======================================
样例输入四:
3 1 2 3
3 4 5 6
样例输出四:
A and B are disjoint
======================================
样例输入五:
2 1 2
2 2 3
样例输出五:
I'm confused!
======================================
Source
经典例题。
hash函数:hash(k):=k mod 129971;
这是从小于130000的最大素数。
若取100001则会超时。
var
procedure init;
var
begin
end;
function hash(i:longint):longint;
begin
end;
function locatea(x:longint):longint;
var
begin
end;
function locateb(x:longint):longint;
var
begin
end;
procedure main;
var
begin
end;
begin
end.