Orig Description
Score : 200 points
Problem StatementWe have a grid with N rows and M columns of squares. Initially, all the squares are white.
There is a button attached to each row and each column.
When a button attached to a row is pressed, the colors of all the squares in that row are inverted; that is, white squares become black and vice versa.
When a button attached to a column is pressed, the colors of all the squares in that column are inverted.
Takahashi can freely press the buttons any number of times. Determine whether he can have exactly K black squares in the grid.
Constraints
1 \leq N,M \leq 1000
0 \leq K \leq NM
InputInput is given from Standard Input in the following format:
N M K
OutputIf Takahashi can have exactly K black squares in the grid, print Yes; otherwise, print No.
Sample Input 12 2 2
Sample Output 1Yes
Press the buttons in the order of the first row, the first column.
Sample Input 22 2 1
Sample Output 2No
Sample Input 33 5 8
Sample Output 3Yes
Press the buttons in the order of the first column, third column, second row, fifth column.
Sample Input 47 9 20
Sample Output 4No
Extracted Specification
An integer N (1 ≤ N ≤ 1000), representing some quantity or size.
An integer M (1 ≤ M ≤ 1000), representing some quantity or size.
An integer K (0 ≤ K ≤ N * M).
### Example Input:
```
2 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! I can create a test case generator for the given problem statement. Below is the test case generator for the problem:
```python
import random
def tcgen():
# Constraints
N = random.randint(1, 1000)
M = random.randint(1, 1000)
K = random.randint(0, N * M)
return N, M, K
# Example usage:
for _ in range(5): # Generate 5 test cases
N, M, K = tcgen()
print(f"N = {N}, M = {M}, K = {K}")
```
This Python function `tcgen()` generates random test cases according to the constraints specified in the problem statement. Here's how it works:
- `N` is the number of rows, randomly chosen from 1 to 1000.
- `M` is the number of columns, randomly chosen from 1 to 1000.
- `K` is the number of black squares desired, randomly chosen from 0 to `N * M`.
This generator will help you create a variety of test cases to validate the solution to your problem.
Extract Arguments
def extract_arguments(fh):
N, M, K = map(int, fh.readline().strip().split())
return N, M, K