Orig Description
Score : 1600 points
Problem StatementThere are N zeros and M ones written on a blackboard.
Starting from this state, we will repeat the following operation: select K of the rational numbers written on the blackboard and erase them, then write a new number on the blackboard that is equal to the arithmetic mean of those K numbers.
Here, assume that N + M - 1 is divisible by K - 1.
Then, if we repeat this operation until it is no longer applicable, there will be eventually one rational number left on the blackboard.
Find the number of the different possible values taken by this rational number, modulo 10^9 + 7.
Constraints
1 ≦ N, M ≦ 2000
2 ≦ K ≦ 2000
N + M - 1 is divisible by K - 1.
InputThe input is given from Standard Input in the following format:
N M K
OutputPrint the number of the different possible values taken by the rational number that will be eventually left on the blackboard, modulo 10^9 + 7.
Sample Input 12 2 2
Sample Output 15
There are five possible values for the number that will be eventually left on the blackboard: \frac{1}{4}, \frac{3}{8}, \frac{1}{2}, \frac{5}{8} and \frac{3}{4}.
For example, \frac{3}{8} can be eventually left if we:
Erase 0 and 1, then write \frac{1}{2}.
Erase \frac{1}{2} and 1, then write \frac{3}{4}.
Erase 0 and \frac{3}{4}, then write \frac{3}{8}.
Sample Input 23 4 3
Sample Output 29
Sample Input 3150 150 14
Sample Output 3937426930
Extracted Specification
An integer N (1 ≤ N ≤ 2000).
An integer M (1 ≤ M ≤ 2000).
An integer K (2 ≤ K ≤ 2000).
### Example Input:
```
12
2
2
```
### Function Signature:
Write a function f(N, M, K) that takes in the input.
def f(N: int, M: int, K: int):
'''
N: an integer
M: an integer
K: an integer
'''
Test Case Generator
Sure! Here is a test case generator for the given problem statement:
```python
import random
def is_valid(N, M, K):
return (N + M - 1) % (K - 1) == 0
def tcgen():
N = random.randint(1, 2000)
M = random.randint(1, 2000)
K = random.randint(2, 2000)
while not is_valid(N, M, K):
N = random.randint(1, 2000)
M = random.randint(1, 2000)
K = random.randint(2, 2000)
return N, M, K
# Generate a test case
N, M, K = tcgen()
print(N, M, K)
```
### Explanation:
1. **Import Random Module**: We use the `random` module to generate random values.
2. **Validation Function**: The function `is_valid(N, M, K)` ensures that the condition \(N + M - 1\) is divisible by \(K - 1\).
3. **Test Case Generator (tcgen)**:
- Randomly generate values for \(N\) and \(M\) within the range [1, 2000].
- Randomly generate a value for \(K\) within the range [2, 2000].
- Check if the generated values satisfy the condition mentioned in the problem statement. If not, regenerate the values until the condition is met.
4. **Generate and Print**: Finally, the function generates a valid test case and prints it.
This generator produces a random valid test case for the problem statement. You can run this generator multiple times to get different test cases for thorough testing.
Extract Arguments
def extract_arguments(fh):
N, M, K = map(int, fh.readline().strip().split())
return N, M, K