luogu#P3795. 钟氏映射
钟氏映射
Background
In the year 2233, the math teacher and math contest advisor Zhong JG at CSSYZ School is already over 2200 years old. To celebrate the birthday, they gave a problem to the public.
Problem Description
Let . Let be a mapping from to . Count the number of distinct mappings that satisfy . Since the answer may be large, output the result modulo .
Input Format
A single positive integer .
Output Format
Output the number of distinct mappings satisfying , modulo .
3
4
Hint
For , the four mappings are:
| f(1) | f(2) | f(3) |
|---|---|---|
| 1 | 2 | 3 |
| 3 | 2 | |
| 2 | 1 | 3 |
| 3 | 2 | 1 |
Constraints:
- For 20% of the testdata, .
- For the other 80% of the testdata, .
Memory 20 MB... (I initially set 1 MB and got myself into trouble).
Translated by ChatGPT 5