Multiple_hash

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
struct ss{
unsigned long long a, b, c, d, e, f;

int randval[100010];
ss(){
a=b=c=d=e=f=0;
for(int i = 0; i <= 100010; i ++)
randval[i] = random(1, (int)1e9);
}
ss(int a, int b, int c, int d, int e, int f):a(a), b(b), c(c), d(d), e(e), f(f){
for(int i = 0; i <= 100010; i ++)
randval[i] = random(1, (int)1e9);
}
ss(ll x){
a=x;
b=x*23;
c=x*x*x;
d=randval[x];
e=x*x;
f=(ll)sqrt(x);
}

ss operator -=(ss t1){
a-=t1.a;
b-=t1.b;
c-=t1.c;
d-=t1.d;
e-=t1.e;
f-=t1.f;
return *this;
}

ss operator +=(ss t1){
a+=t1.a;
b+=t1.b;
c+=t1.c;
d+=t1.d;
e+=t1.e;
f+=t1.f;
return *this;
}

bool operator ==(ss t1){
return a==t1.a&&b==t1.b&&c==t1.c&&d==t1.d&&e==t1.e&&f==t1.f;
}
};
ss operator + (ss t1, ss t2){
return ss(t1.a+t2.a,t1.b+t2.b,t1.c+t2.c,t1.d+t2.d,t1.e+t2.e,t1.f+t2.f);
}