CF111C.Petya and Spiders
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Little Petya loves training spiders. Petya has a board n × m in size. Each cell of the board initially has a spider sitting on it. After one second Petya chooses a certain action for each spider, and all of them humbly perform its commands. There are 5 possible commands: to stay idle or to move from current cell to some of the four side-neighboring cells (that is, one command for each of the four possible directions). Petya gives the commands so that no spider leaves the field. It is allowed for spiders to pass through each other when they crawl towards each other in opposite directions. All spiders crawl simultaneously and several spiders may end up in one cell. Petya wants to know the maximum possible number of spider-free cells after one second.
小佩佳喜欢训练蜘蛛。佩佳有一块大小为 n×m 的棋盘,初始时每个格子上都坐着一只蜘蛛。一秒后,佩佳会为每只蜘蛛指定一个动作,所有蜘蛛都会恭敬地执行该指令。共有 5 种可能的指令:原地不动,或向四个正交相邻格子之一移动(即上下左右四个方向各对应一种指令)。佩佳下达指令时需保证没有任何蜘蛛离开棋盘。当两只蜘蛛沿相反方向彼此相向爬行时,允许它们互相穿过。所有蜘蛛同时爬行,因此多个蜘蛛可能最终到达同一个格子。佩佳想知道:经过一秒后,最多可能有多少个没有蜘蛛的格子?
输入格式
The first line contains two space-separated integers n and m (1 ≤ n, m ≤ 40, n·m ≤ 40) — the board sizes.
第一行包含两个以空格分隔的整数 n 和 m(1 ≤ n, m ≤ 40,且 n⋅m ≤ 40)——表示棋盘的尺寸。
输出格式
In the first line print the maximum number of cells without spiders.
在第一行输出没有蜘蛛的单元格的最大数量。
输入输出样例
输入#1
1 1
输出#1
0
输入#2
2 3
输出#2
4
说明/提示
In the first sample the only possible answer is:
s
In the second sample one of the possible solutions is:
rdl
rul
s denotes command "stay idle", l, r, d, u denote commands "crawl left", "crawl right", "crawl down", "crawl up", correspondingly.
在第一个样例中,唯一可能的答案是:
s
在第二个样例中,一个可能的解是:
rdl
rul
其中,s 表示命令“保持静止”,l、r、d、u 分别表示命令“向左爬行”、“向右爬行”、“向下爬行”、“向上爬行”。
输入解题思路,AI测评打分。不知道怎么写?