EPIC Institute of Technology Round August 2024 (Div. 1 + Div. 2)
A
Distanced Coloring
Codeforces
800
原题
←B →
翻译中…

You received an $n\times m$ grid from a mysterious source. The source also gave you a magic positive integer constant $k$.

翻译中…

The source told you to color the grid with some colors, satisfying the following condition:

翻译中…
  • If $(x_1,y_1)$, $(x_2,y_2)$ are two distinct cells with the same color, then $\max(|x_1-x_2|,|y_1-y_2|)\ge k$.
翻译中…

You don't like using too many colors. Please find the minimum number of colors needed to color the grid.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1\le t\le1000$). The description of the test cases follows.

翻译中…

The only line of each test case consists of three positive integers $n$, $m$, $k$ ($1\le n,m,k\le10^4$) — the dimensions of the grid and the magic constant.

翻译中…

Output

翻译中…

For each test case, print a single integer — the minimum number of colors needed to color the grid.

翻译中…

Note

翻译中…

In the first test case, one of the optimal constructions is:

翻译中…

image

翻译中…

In the second test case, the color of all cells must be pairwise different, so the answer is $5$.

翻译中…

样例

Input #1
6
3 3 2
5 1 10000
7 3 4
3 2 7
8 9 6
2 5 4
Output #1
4
5
12
6
36
8
InputCopy OutputCopy
题目信息
题号
2002A
时间限制
1 s
内存限制
256 MB
标签
构造
模拟
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。