Hash the Array
nnumbers, you are asked to calculate the total hash of all of those numbers. To compute the hash value for an array of numbers, we can use this formula:
Note that it’s more optimal to calculate the powers of
127by multiplying the previous power by
127on every iteration. Also, keep in mind that computing the mod at the end is the same as computing the mod for each element and then summing those together.
The first line of the input contains a single integer
n(1 ≤ n ≤ 100 000).
The next line contains
nspace-separated integers (0 ≤ ≤ ).
The program should print the resulting hash of the array.
5 1 2 3 7 10
5 7 1 2 3 10
Time limit: 1 seconds
Memory limit: 512 MB
Output limit: 1 MB