Codeforces Round 645 (Div. 2)
A
Park Lighting
Codeforces
800
原题
←B →
翻译中…

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 $n$ rows and $m$ 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 $1$. For example, park with $n=m=2$ has $12$ 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).

翻译中…

image The park sizes are: $n=4$, $m=5$. The lighted squares are marked yellow. Please note that all streets have length $1$. 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.

翻译中…

Input

翻译中…

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

翻译中…

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

翻译中…

Output

翻译中…

Print $t$ 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.

翻译中…

Note

翻译中…

Possible optimal arrangement of the lanterns for the $2$-nd test case of input data example: image

翻译中…

Possible optimal arrangement of the lanterns for the $3$-rd test case of input data example: image

翻译中…

样例

Input #1
5
1 1
1 3
2 2
3 3
5 3
Output #1
1
2
2
5
8
InputCopy OutputCopy
题目信息
题号
1358A
时间限制
2 s
内存限制
256 MB
标签
贪心
数学

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