Partitions into K Groups
Count the ways to partition N labelled items into exactly K non-empty unlabelled groups — the Stirling number S(N, K) — modulo 109+7.
Input: one line with two integers N and K.
Output: S(N, K) mod 109+7.
Constraints:
- 1 ≤ K ≤ N ≤ 106
Sample Tests
Input 1
4 2
Output 1
7
Input 2
3 3
Output 2
1
Discussion (opens after you solve — no spoilers before)
No comments yet.