CF1358A.Park Lighting

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Due to the coronavirus pandemic, city authorities obligated citizens to keep a social distance. The mayor of the city Semyon wants to light up Gluharniki park so that people could see each other even at night to keep the social distance.

The park is a rectangular table with nn rows and mm columns, where the cells of the table are squares, and the boundaries between the cells are streets. External borders are also streets. Every street has length 11. For example, park with n=m=2n=m=2 has 1212 streets.

You were assigned to develop a plan for lighting the park. You can put lanterns in the middle of the streets. The lamp lights two squares near it (or only one square if it stands on the border of the park).

The park sizes are: n=4n=4, m=5m=5. The lighted squares are marked yellow. Please note that all streets have length 11. Lanterns are placed in the middle of the streets. In the picture not all the squares are lit.

Semyon wants to spend the least possible amount of money on lighting but also wants people throughout the park to keep a social distance. So he asks you to find the minimum number of lanterns that are required to light all the squares.

由于新冠疫情,城市当局要求市民保持社交距离。城市市长谢苗希望点亮格鲁哈尔尼基公园,以便人们即使在夜间也能彼此看见,从而保持社交距离。

公园是一个具有 nn 行 mm 列的矩形表格,其中表格的每个单元格为正方形,单元格之间的边界为街道,外部边界也均为街道。每条街道长度均为 11。例如,当 n=m=2n = m = 2 时,公园共有 1212 条街道。

你被委派制定公园的照明方案。你可以在街道的中点处安装灯笼。一盏灯笼可照亮其两侧相邻的两个正方形(若灯笼位于公园边界上,则仅能照亮一侧的一个正方形)。

公园尺寸为:n=4n = 4,m=5m = 5。图中被照亮的正方形标为黄色。请注意,所有街道长度均为 11,灯笼均置于街道中点。图中并非所有正方形均被照亮。

谢苗希望以最少的资金投入完成公园照明,同时确保公园内所有人员均能保持社交距离。因此,他请你找出能够照亮全部正方形所需的最少灯笼数量。

输入格式

The first line contains a single integer tt (1≤t≤1041 \le t \le 10^4) — the number of test cases in the input. Then tt test cases follow.

Each test case is a line containing two integers nn, mm (1≤n,m≤1041 \le n, m \le 10^4) — park sizes.

第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4)—— 输入中测试用例的数量。随后是 tt 个测试用例。

每个测试用例是一行,包含两个整数 nn、mm(1≤n,m≤1041 \le n, m \le 10^4)—— 公园的尺寸。

输出格式

Print tt answers to the test cases. Each answer must be a single integer — the minimum number of lanterns that are required to light all the squares.

输出 tt 个测试用例的答案。每个答案必须是一个整数——即照亮所有方格所需的最少灯笼数量。

输入输出样例

  • 输入#1

    5
    1 1
    1 3
    2 2
    3 3
    5 3

    输出#1

    1
    2
    2
    5
    8

说明/提示

Possible optimal arrangement of the lanterns for the 22-nd test case of input data example:

Possible optimal arrangement of the lanterns for the 33-rd test case of input data example:

第 2 个输入数据样例测试用例的灯笼可能最优排列:

第 3 个输入数据样例测试用例的灯笼可能最优排列:

输入解题思路,AI测评打分。不知道怎么写?

首页