#P7322. 「PMOI-4」排列变换
「PMOI-4」排列变换
Description
Given a constant . For a permutation of length , define
$$f(a)=\{\max_{1 \le i \le k} \{a_i\},\max_{2 \le i \le k+1} \{a_i\},\cdots,\max_{n-k+1 \le i \le n} \{a_i\}\}$$For a sequence of length , define its weight as the number of distinct values in .
Now, wants to know, for all permutations of length , the sum of .
Input Format
One line contains two positive integers .
Output Format
Output one integer in one line, representing the answer.
Since the answer may be very large, you need to take it modulo .
3 2
10
500000 200000
840847204
Hint
[Sample Explanation]
- , , so .
- , , so .
- , , so .
- , , so .
- , , so .
- , , so .
The answer is .
[Constraints]
This problem uses bundled testdata.
- Subtask 1 (10pts): .
- Subtask 2 (10pts): .
- Subtask 3 (30pts): .
- Subtask 4 (20pts): .
- Subtask 5 (20pts): .
- Subtask 6 (10pts): no special constraints.
For of the data, .
[Notes]
-
is a permutation of length if and only if every integer in appears in exactly once.
For example, and are permutations of length and , respectively, while is not a permutation of length , is not a permutation of length , and is not a permutation of length . -
This problem is not difficult.
Translated by ChatGPT 5
京公网安备 11011102002149号