#P3200. [HNOI2009] 有趣的数列
[HNOI2009] 有趣的数列
Description
We call a sequence of length interesting if and only if it satisfies the following three conditions:
- It is a permutation of the integers from to , written as .
- All odd-indexed terms satisfy , and all even-indexed terms satisfy .
- For every adjacent pair and , it holds that .
For a given , find the number of different interesting sequences of length . Since the answer can be large, output the answer modulo .
Input Format
One line with two positive integers .
Output Format
Output a single integer on one line, the answer.
3 10
5
Hint
Constraints
For of the testdata, .
For of the testdata, , .
Sample explanation
The interesting sequences are (1, 2, 3, 4, 5, 6), (1, 2, 3, 5, 4, 6), (1, 3, 2, 4, 5, 6), (1, 3, 2, 5, 4, 6), (1, 4, 2, 5, 3, 6).
Translated by ChatGPT 5
京公网安备 11011102002149号