Editorial
Group 1. .
In this group, since it is guaranteed that is divisible by , the only case possible is . In this case, the one and only square on a grid is white. Thus, the answer is .
Group 2.
In this group, the described grid is a regular chessboard, and our task is to count the number of white cells on it.
Now we can divide the problem into two parts:
is even: in this case, we can always divide the board into pairs of neighbor rows, starting from the first one, and in the same columns all these pairs will have cells of two different colors, which means that the number of both colors will be equal. The total number of cells on the board is , thus the number of white cells is .
is odd: in this case, we can divide the last rows (from -th to -th) as in the case of even , and the first row will be left. It has an odd number of cells in it and the colors of these cells alternate, thus the number of colors will differ by one. Also, this row starts with a white cell. That means that there will be more white cells than the black ones. So, there will be white cells in this row, and on the whole board there will be = of them.
So, the answer is for even and for odd . But, actually, these two cases can be simplified to a single formula: .
Group 3. is even.
In this case, we need to calculate the number of white cells on a "big" chess board as in the case of even in the previous group, but we need to take as because it is the side of this board in this group. Then, we need to multiply what we get by , which is the size of each of the "big" white cells.
Group 4. no additional constraints.
This group is almost similar to the third one, but the case of the odd is included here.
All the groups can be solved with time and memory complexity.