Problem B
Magic Sequence
One day, Bob discovers a magic sequence
-
= -
= ( * + ) %
Bob is really thrilled to share his invention with his crush, Alice. However, he knows that Alice does not like numbers without any specific ordering. Hence, he wants to sort the sequence before giving it to her. Please help Bob to make a progress in his relationship with Alice!
Suppose that
V = 0 for i from 0 to N - 1: V = (V * X + R[i]) % Y;
Input
The first line of input contains an integer
-
The first line contains one integer
. -
The second line contains three integers
, , and . -
The third line contains two integers
and .
Output
For each test case, output the hash value of
Subtasks
-
: , -
: -
: -
: No additional constraint.
Sample Input 1 | Sample Output 1 |
---|---|
3 7 7 7 12 1 20 7 16 1 15 1 14 7 2 5 6 1 19 |
0 1 8 |