Onto Functions
Count the surjective (onto) functions from an N-element set to a K-element set, modulo 109+7.
Input: one line with two integers N and K.
Output: the number of surjections mod 109+7.
Constraints:
- 1 ≤ K ≤ N ≤ 106
Sample Tests
Input 1
3 2
Output 1
6
Input 2
2 2
Output 2
2
Discussion (opens after you solve — no spoilers before)
No comments yet.