Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Hash
- {
- int h1,h2;
- Hash():h1(0),h2(0){}
- Hash(int x):
- h1(x%M1),h2(x%M2){}
- Hash(int x,int y):
- h1(x%M1),h2(y%M2){}
- Hash(long long x,long long y):
- h1(x%M1),h2(y%M2){}
- Hash operator + (const Hash &other) const{
- return {h1 + other.h1,h2 + other.h2};
- }
- Hash operator - (const Hash &other) const{
- return {h1 - other.h1 + M1,h2 - other.h2 + M2};
- }
- Hash operator * (const Hash &other) const{
- return {1ll * h1 * other.h1,1ll * h2 * other.h2};
- }
- bool operator == (const Hash &other) const{
- return h1 == other.h1 && h2 == other.h2;
- }
- bool operator != (const Hash &other) const{
- return h1 != other.h1 || h2 != other.h2;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement