#P9084. [PA 2018] Skwarki
[PA 2018] Skwarki
Problem Description
This problem is translated from PA 2018 Round 5 Skwarki.
Find how many sequences of length satisfy the following conditions:
- Each of the numbers to appears exactly once in the sequence.
- Only after performing exactly operations, the sequence becomes a sequence with only one element.
The operation is defined as follows:
Let be the -th element of the sequence (, where is the sequence length). If or , then mark . If , then mark . If , then mark .
Then, delete all marked elements from the sequence.
There may be many valid sequences, so please output the answer modulo .
Input Format
The input contains only one line with three integers .
Output Format
Output one integer per line, representing the number of valid sequences modulo .
5 3 100000007
4
Hint
Sample 1 Explanation
All valid sequences are listed below:
Constraints
This problem uses bundled testdata.
For of the testdata, it is guaranteed that , , and .
Translated by ChatGPT 5