QOJ.ac

QOJ

时间限制: 10 s 内存限制: 512 MB 总分: 100

#1262. 人人平等

统计

假设桌上有 $n$ 个两两不同的数,记为 $a_1, a_2, \dots, a_n$(顺序很重要)。在一次操作中,你可以选择两个不同的下标 $i_1 < i_2$,并同时将 $a_{i_1}$ 和 $a_{i_2}$ 加 1。唯一的限制是桌上的数在任何时刻都必须保持两两不同。你的任务是求出得到两两不同的数 $b_1, b_2, \dots, b_n$(顺序严格对应)的方法数。由于该数字可能非常大,请输出其对 $998\,244\,353$ 取模的结果。

输入格式

第一行包含一个整数 $n$ ($1 \le n \le 30$)。第二行和第三行分别包含 $n$ 个以空格分隔的整数,分别为数组 $a_i$ 和 $b_i$ ($1 \le a_i, b_i \le 200$)。保证所有 $a_i$ 两两不同,$b_i$ 亦然。

输出格式

输出答案对质数 $998\,244\,353$ 取模的结果。

样例

样例输入 1

3
1 2 3
3 4 5

样例输出 1

1

样例输入 2

3
1 2 3
7 8 9

样例输出 2

42

样例输入 3

3
1 4 7
3 6 9

样例输出 3

6

说明

在第一个样例中,唯一的方法是按 $\{2, 3\}, \{1, 3\}, \{1, 2\}$ 的顺序进行操作。

在第三个样例中,我们可以按任意顺序进行这三次操作 $\{1, 2\}, \{2, 3\}, \{1, 3\}$。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#840EditorialOpen题解alpha10222026-01-28 02:15:47View

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.