Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. struct Hash
  2. {
  3. int h1,h2;
  4.  
  5. Hash():h1(0),h2(0){}
  6. Hash(int x):
  7. h1(x%M1),h2(x%M2){}
  8. Hash(int x,int y):
  9. h1(x%M1),h2(y%M2){}
  10. Hash(long long x,long long y):
  11. h1(x%M1),h2(y%M2){}
  12.  
  13. Hash operator + (const Hash &other) const{
  14. return {h1 + other.h1,h2 + other.h2};
  15. }
  16. Hash operator - (const Hash &other) const{
  17. return {h1 - other.h1 + M1,h2 - other.h2 + M2};
  18. }
  19. Hash operator * (const Hash &other) const{
  20. return {1ll * h1 * other.h1,1ll * h2 * other.h2};
  21. }
  22. bool operator == (const Hash &other) const{
  23. return h1 == other.h1 && h2 == other.h2;
  24. }
  25. bool operator != (const Hash &other) const{
  26. return h1 != other.h1 || h2 != other.h2;
  27. }
  28. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement