Distanced Coloring
题面翻译
你从一个神秘的来源收到了一个 n × m n\times m n×m 网格。这个来源还给了你一个神奇的正整数 k k k 。
消息来源告诉你要用一些颜色给网格着色,并满足以下条件:
- 如果 ( x 1 , y 1 ) (x_1,y_1) (x1,y1) , ( x 2 , y 2 ) (x_2,y_2) (x2,y2) 是两个颜色相同的单元格,那么 max ( ∣ x 1 − x 2 ∣ , ∣ y 1 − y 2 ∣ ) ≥ k \max(|x_1-x_2|,|y_1-y_2|)\ge k max(∣x1−x2∣,∣y1−y2∣)≥k 。
您不喜欢使用过多的颜色。请找出给网格着色并满足条件的所需的最少颜色数。
多组数据, 1 ≤ t ≤ 1000 1\le t\le1000 1≤t≤1000, 1 ≤ n , m , k ≤ 1 0 4 1\le n,m,k\le10^4 1≤n,m,k≤104。
by @wrkwrkwrk。
题目描述
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.
输入格式
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.
输出格式
For each test case, print a single integer — the minimum number of colors needed to color the grid.
样例 #1
样例输入 #1
6
3 3 2
5 1 10000
7 3 4
3 2 7
8 9 6
2 5 4
样例输出 #1
4
5
12
6
36
8
提示说明
In the first test case, one of the optimal constructions is:
In the second test case, the color of all cells must be pairwise different, so the answer is $ 5 $ .
代码内容
// #include <iostream>
// #include <algorithm>
// #include <cstring>
// #include <stack>//栈
// #include <deque>//队列
// #include <queue>//堆/优先队列
// #include <map>//映射
// #include <unordered_map>//哈希表
// #include <vector>//容器,存数组的数,表数组的长度
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll t;
cin>>t;
while(t--)
{
ll n,m,k;
cin>>n>>m>>k;
cout<<min(n,k)*min(m,k)<<endl;
}
return 0;
}