Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a = int(input())
- m = int(input())
- s = input()
- def get_hash(a, m, s):
- res = 0
- x = 1
- for sym in reversed(s):
- res = (res + ord(sym) * x) % m
- x *= a
- return res
- print(get_hash(a, m, s))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement