CF142B.Help General
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Once upon a time in the Kingdom of Far Far Away lived Sir Lancelot, the chief Royal General. He was very proud of his men and he liked to invite the King to come and watch drill exercises which demonstrated the fighting techniques and tactics of the squad he was in charge of. But time went by and one day Sir Lancelot had a major argument with the Fairy Godmother (there were rumors that the argument occurred after the general spoke badly of the Godmother's flying techniques. That seemed to hurt the Fairy Godmother very deeply).
As the result of the argument, the Godmother put a rather strange curse upon the general. It sounded all complicated and quite harmless: "If the squared distance between some two soldiers equals to 5, then those soldiers will conflict with each other!"
The drill exercises are held on a rectangular n × m field, split into nm square 1 × 1 segments for each soldier. Thus, the square of the distance between the soldiers that stand on squares (_x_1, _y_1) and (_x_2, _y_2) equals exactly (_x_1 - _x_2)2 + (_y_1 - _y_2)2. Now not all nm squad soldiers can participate in the drill exercises as it was before the Fairy Godmother's curse. Unless, of course, the general wants the soldiers to fight with each other or even worse... For example, if he puts a soldier in the square (2, 2), then he cannot put soldiers in the squares (1, 4), (3, 4), (4, 1) and (4, 3) — each of them will conflict with the soldier in the square (2, 2).
Your task is to help the general. You are given the size of the drill exercise field. You are asked to calculate the maximum number of soldiers that can be simultaneously positioned on this field, so that no two soldiers fall under the Fairy Godmother's curse.
很久以前,在遥远遥远的王国里,住着皇家总司令兰斯洛特爵士。他非常为自己的士兵们感到自豪,常常邀请国王前来观看操练演习,以展示他所统率的小队的战斗技巧与战术。但时光流逝,某一天,兰斯洛特爵士与仙女教母发生了严重争执(据传言,争执起因是这位将军对教母的飞行技巧发表了不当言论,这似乎深深伤害了仙女教母)。
作为这场争执的结果,教母对将军施下了一道颇为奇特的诅咒。其内容听起来既复杂又无害:“若两名士兵之间的距离的平方等于 5,则这两名士兵将彼此冲突!”
操练演习在一块大小为 n×m 的矩形场地上进行,该场地被划分为 nm 个边长为 1×1 的正方形格子,每名士兵占据其中一个格子。因此,站在格子 (x1,y1) 与 (x2,y2) 上的两名士兵之间的距离的平方恰好为 (x1−x2)2+(y1−y2)2。如今,并非全部 nm 名士兵都能像仙女教母施咒前那样同时参与操练演习——除非将军希望士兵们彼此争斗,甚至更糟……例如,若他在格子 (2,2) 上部署一名士兵,则他不能在格子 (1,4)、(3,4)、(4,1) 和 (4,3) 上再部署士兵——因为这些位置上的士兵都将与 (2,2) 处的士兵发生冲突。
你的任务是帮助这位将军。你将获得操练场地的尺寸。你需要计算:在此场地上最多可同时部署多少名士兵,使得任意两名士兵之间均不满足仙女教母诅咒的条件(即任意两名士兵之间的距离的平方均不等于 5)。
输入格式
The single line contains space-separated integers n and m (1 ≤ n, m ≤ 1000) that represent the size of the drill exercise field.
单行包含两个以空格分隔的整数 n 和 m(1 ≤ n, m ≤ 1000),表示操练场地的尺寸。
输出格式
Print the desired maximum number of warriors.
输出期望的最大战士数量。
输入输出样例
输入#1
2 4
输出#1
4
输入#2
3 4
输出#2
6
说明/提示
In the first sample test Sir Lancelot can place his 4 soldiers on the 2 × 4 court as follows (the soldiers' locations are marked with gray circles on the scheme):

In the second sample test he can place 6 soldiers on the 3 × 4 site in the following manner:

在第一个样例测试中,兰斯洛特爵士可以将他的 4 名士兵布置在 2×4 的场地上,如下所示(士兵的位置在示意图中用灰色圆圈标出):

在第二个样例测试中,他可以将 6 名士兵以如下方式布置在 3×4 的场地上:

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