Distanced Coloring

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(x1x2,y1y2)k

您不喜欢使用过多的颜色。请找出给网格着色并满足条件的所需的最少颜色数。

多组数据, 1 ≤ t ≤ 1000 1\le t\le1000 1t1000 1 ≤ n , m , k ≤ 1 0 4 1\le n,m,k\le10^4 1n,m,k104

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;
}



    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Pretty Boy Fox

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值