#C946. Color Grid Operations
Color Grid Operations
Color Grid Operations
You are given a grid with n rows and m columns. In one operation, you color a portion of the grid. Your task is to determine the minimum number of operations required to ensure that every cell of the grid is colored at least once.
The problem can be summarized as follows:
If either n or m is odd, the entire grid can be colored in just one operation. Otherwise, if both are even, two operations are necessary. In mathematical terms, the answer ans is given by:
[ ans = \begin{cases} 1, & \text{if } n\bmod 2 = 1 \text{ or } m\bmod 2 = 1 \ 2, & \text{if } n\bmod 2 = 0 \text{ and } m\bmod 2 = 0 \end{cases} ]
Write a program that reads the grid dimensions from standard input and prints the minimum number of operations needed to color the grid to standard output.
inputFormat
The input consists of a single line with two space-separated integers n and m which denote the number of rows and columns in the grid respectively.
outputFormat
Output a single integer which is the minimum number of operations required to color the entire grid.
## sample3 3
1