# Розбір

Group 1. $n=1$.

In this group, since it is guaranteed that $n$ is divisible by $k$, the only case possible is $n=k=1$. In this case, the one and only square on a grid is white. Thus, the answer is $1$.

Group 2. $k=1$

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:

$n$ 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 $n⋅n$, thus the number of white cells is $2n⋅n $.

$n$ is odd: in this case, we can divide the last $n−1$ rows (from $2$-th to $n$-th) as in the case of even $n$, 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 $2n−1 +1$ white cells in this row, and on the whole board there will be $2n⋅(n−1) +2n−1 +1=2n⋅n−n+n−1+2 $ = $2n⋅n+1 $ of them.

So, the answer is $2n⋅n $ for even $n$ and $2n⋅n+1 $ for odd $n$. But, actually, these two cases can be simplified to a single formula: $⌈2n⋅n ⌉$.

Group 3. $kn $ 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 $n$ in the previous group, but we need to take $kn $ as $n$ because it is the side of this board in this group. Then, we need to multiply what we get by $k⋅k$, 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 $kn $ is included here.

All the groups can be solved with $O(1)$ time and memory complexity.