#abc247f. F - Cards
F - Cards
Score : points
问题陈述
有 张卡片,编号分别为 。第 张卡片正面写有 ,背面写有 。 这里, 和 是 的排列。
在满足以下条件的情况下,有多少种方法可以从这 张卡片中选择一些卡片?请计算满足条件的方案数对 取模的结果。
条件:每个数字 至少在一个被选中的卡片上出现。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are cards numbered . Card has written on the front and written on the back.
Here, and are permutations of .
How many ways are there to choose some of the cards such that the following condition is satisfied? Find the count modulo .
Condition: every number is written on at least one of the chosen cards.
Constraints
- and are permutations of .
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
3
1 2 3
2 1 3
Sample Output 1
3
For example, if you choose Cards and , then is written on the front of Card , on the back of Card , and on the front of Card , so this combination satisfies the condition.
There are ways to choose cards satisfying the condition: .
Sample Input 2
5
2 3 5 4 1
4 2 1 3 5
Sample Output 2
12
Sample Input 3
8
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8
Sample Output 3
1
update @ 2024/3/10 10:36:08