123456789101112 |
- def xhash(coeff, exp):
- sign = 1
- if coeff < 0:
- sign = -1
- coeff = -coeff
- if exp >= 0:
- exp_hash = pow(10, exp, _PyHASH_MODULUS)
- else:
- exp_hash = pow(_PyHASH_10INV, -exp, _PyHASH_MODULUS)
- hash_ = coeff * exp_hash % _PyHASH_MODULUS
- ans = hash_ if sign == 1 else -hash_
- return -2 if ans == -1 else ans
|