Description
Let the universal set be U.
An operation scheme is defined as assigning to each non-empty subset S⊆U a representative element r(S) chosen from S.
An operation scheme is good if and only if for every non-empty subset S⊆U, it satisfies the following: for any partition of S into m non-empty subsets A1,A2,…,Am, there exists 1≤i≤m such that r(Ai)=r(S).
Given U={1,2,…,n}, compute the number of essentially distinct good operation schemes modulo 1000000087.
Two operation schemes are essentially distinct if and only if there exists at least one non-empty subset S⊆U where r(S) differs between the two schemes.
A single line containing two positive integers n,m.
A single integer, the number of good operation schemes modulo 1000000087.
3 1
24
3 2
6
4 3
2592
114514 3
750017326
114514 19198
274658403
Hint
Sample Explanation #1
All schemes are good, so the answer is 13×23×3=24.
Sample Explanation #2
The six valid schemes are:
- r({1,2,3})=1, r({1,2})=1, r({1,3})=1, r({2,3})=2, r({1})=1, r({2})=2, r({3})=3;
- r({1,2,3})=1, r({1,2})=1, r({1,3})=1, r({2,3})=3, r({1})=1, r({2})=2, r({3})=3;
- r({1,2,3})=2, r({1,2})=2, r({1,3})=1, r({2,3})=2, r({1})=1, r({2})=2, r({3})=3;
- r({1,2,3})=2, r({1,2})=2, r({1,3})=3, r({2,3})=2, r({1})=1, r({2})=2, r({3})=3;
- r({1,2,3})=3, r({1,2})=1, r({1,3})=3, r({2,3})=3, r({1})=1, r({2})=2, r({3})=3;
- r({1,2,3})=3, r({1,2})=2, r({1,3})=3, r({2,3})=3, r({1})=1, r({2})=2, r({3})=3.
Data Range
This problem uses subtasks with bundled testing.
- Subtask 1 (5 pts): m=2.
- Subtask 2 (6 pts): n≤4.
- Subtask 3 (10 pts): n≤3×103.
- Subtask 4 (18 pts): m=1.
- Subtask 5 (26 pts): m≤3×103.
- Subtask 6 (35 pts): No additional constraints.
For all test cases: 1≤m<n≤2×105.
Translation by DeepSeek R1