Time Limit: 2 second(s) | Memory Limit: 32 MB |
Consider this sequence {1, 2, 3 ... N}, as an initial sequence of first N natural numbers. You can rearrange this sequence in many ways. There will be a total of N! arrangements. You have to calculate the number of arrangement of first N natural numbers, where in first M positions; exactly K numbers are in their initial position.
For Example, N = 5, M = 3, K = 2
You should count this arrangement {1, 4, 3, 2, 5}, here in first 3 positions 1 is in 1^{st} position and 3 in 3^{rd} position. So exactly 2 of its first 3 are in there initial position.
But you should not count {1, 2, 3, 4, 5}.
Input starts with an integer T (≤ 1000), denoting the number of test cases.
Each case contains three integers N (1 ≤ N ≤ 1000), M (M ≤ N), K (0 < K ≤ M).
For each case, print the case number and the total number of possible arrangements modulo 1000000007.
Sample Input |
Output for Sample Input |
2 5 3 2 10 6 3 |
Case 1: 12 Case 2: 64320 |
Developed and Maintained by
JANE ALAM JAN |
Copyright © 2012
LightOJ, Jane Alam Jan |