Codeforces Round #645 (Div. 2) A. Park Lighting
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).

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.
The first line contains a single integer tt (1≤t≤1041≤t≤104) — 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≤n,m≤104) — park sizes.
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.
5 1 1 1 3 2 2 3 3 5 3
1 2 2 5 8
只会分类讨论的垃圾解法==
#include <bits/stdc++.h> using namespace std; int main() { int t; cin>>t; while(t--) { int n,m; cin>>n>>m; if(n%2==0) { cout<<m*(n/2)<<endl; } else if(m%2==0) { cout<<n*(m/2)<<endl; } else { cout<<m*(n/2)+m/2+1<<endl; } } }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!