QOJ.ac

QOJ

时间限制: 5.0 s 内存限制: 512 MB 总分: 100 可 Hack ✓

#7322. 随机数

统计

Yuuka 拥有 $n$ 个整数 $a_1, a_2, \dots, a_n$,这些数是在 $1$ 到 $10^{18}$ 之间均匀且独立生成的。 Yuuka 选择一个整数 $m$。接下来,生成一个 $0$ 到 $(m - 1)$ 之间的均匀随机整数 $k$。 之后,Yuuka 将每个 $a_i$ 变为 $(a_i + k) \pmod m$。最后,她将这些整数随机打乱,得到结果序列 $b_1, b_2, \dots, b_n$。 现在,给定 $a_1, a_2, \dots, a_n$ 和 $b_1, b_2, \dots, b_n$,你需要求出 $m$ 和 $k$ 的值。

输入格式

第一行包含一个整数 $n$,表示整数的个数 ($10^5 \le n \le 2 \cdot 10^5$)。 第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$:即那 $n$ 个随机生成的整数 ($1 \le a_i \le 10^{18}$)。 第三行包含 $n$ 个整数 $b_1, b_2, \dots, b_n$:即变换后的结果 ($0 \le b_i < 10^{10}$)。 保证存在满足 $0 \le k < m \le 10^{10}$ 的解。

输出格式

在单行内输出两个整数 $m$ 和 $k$。如果存在多个可能的答案,输出其中任意一个即可。

样例

样例输入 1

10
1 15 6 4 2 4 6 18 1 20
6 9 0 9 7 9 0 1 6 3

样例输出 1

11 5

说明

请注意,题目中的样例仅用于展示格式!系统测试中的测试用例将不包含此样例(测试点 1 将是其他测试用例),因为它违反了数据范围限制。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.