Random Numbers
Time limit5sMemory limit512 MB
Given random integers a and a shuffled list b, find m and k so that b is the multiset of (a_i + k) mod m.
- Level
Hard8 of 10
- Topics
- Number theory, Math, Hash map
- Solved
- No attempts yet
Problem
Yuuka has integers , each generated uniformly and independently between and , inclusive.
Yuuka chooses an integer . Next, an integer is generated uniformly between and , inclusive. Then Yuuka changes every to . Finally, she shuffles the integers randomly. The resulting integers are .
Given and , find the values of and .
Input
The first line contains ().
The second line contains integers , randomly generated with .
The third line contains integers with .
It is guaranteed that a solution exists with .
Output
Print and on a single line. If several answers are possible, print any one of them.
Hint
The example in the statement only shows the format. The system tests do not include it (test 1 is a different test), because it violates the constraints.