A10182 | A rectangle
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Developing tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem.
A field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for quick filling of a field part with identical enemy units. This action will look like following: a game designer will select a rectangular area on the map, and each cell whose center belongs to the selected rectangle will be filled with the enemy unit.
More formally, if a game designer selected cells having coordinates $(x_{1},y_{1})$ and $(x_{2},y_{2})$ , where $x_{1}<=x_{2}$ and $y_{1}<=y_{2}$ , then all cells having center coordinates $(x,y)$ such that $x_{1}<=x<=x_{2}$ and $y_{1}<=y<=y_{2}$ will be filled. Orthogonal coordinates system is set up so that one of cell sides is parallel to $OX$ axis, all hexagon centers have integer coordinates and for each integer $x$ there are cells having center with such $x$ coordinate and for each integer $y$ there are cells having center with such $y$ coordinate. It is guaranteed that difference $x_{2}-x_{1}$ is divisible by $2$ .
Working on the problem Petya decided that before painting selected units he wants to output number of units that will be painted on the map.
Help him implement counting of these units before painting.

A field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for quick filling of a field part with identical enemy units. This action will look like following: a game designer will select a rectangular area on the map, and each cell whose center belongs to the selected rectangle will be filled with the enemy unit.
More formally, if a game designer selected cells having coordinates $(x_{1},y_{1})$ and $(x_{2},y_{2})$ , where $x_{1}<=x_{2}$ and $y_{1}<=y_{2}$ , then all cells having center coordinates $(x,y)$ such that $x_{1}<=x<=x_{2}$ and $y_{1}<=y<=y_{2}$ will be filled. Orthogonal coordinates system is set up so that one of cell sides is parallel to $OX$ axis, all hexagon centers have integer coordinates and for each integer $x$ there are cells having center with such $x$ coordinate and for each integer $y$ there are cells having center with such $y$ coordinate. It is guaranteed that difference $x_{2}-x_{1}$ is divisible by $2$ .
Working on the problem Petya decided that before painting selected units he wants to output number of units that will be painted on the map.
Help him implement counting of these units before painting.

输入格式
The only line of input contains four integers $x_{1},y_{1},x_{2},y_{2}$ ( $-10^{9}<=x_{1}<=x_{2}<=10^{9},-10^{9}<=y_{1}<=y_{2}<=10^{9}$ ) — the coordinates of the centers of two cells.
输出格式
Output one integer — the number of cells to be filled.
输入输出样例
输入 #1
1 1 5 5
输出 #1
13
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted