E - A rectangle

E - A rectangle
Time Limit:500MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Description

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 (x1, y1) and (x2, y2), where x1 ≤ x2 and y1 ≤ y2, then all cells having center coordinates (x, y) such that x1 ≤ x ≤ x2 and y1 ≤ y ≤ y2 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 differencex2 - x1 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.

Input

The only line of input contains four integers x1, y1, x2, y2 ( - 109 ≤ x1 ≤ x2 ≤ 109,  - 109 ≤ y1 ≤ y2 ≤ 109) — the coordinates of the centers of two cells.

Output

Output one integer — the number of cells to be filled.

Sample Input

Input
1 1 5 5
Output
13


求X1-X2,Y1-Y2的矩形区域内  正六边形的个数,找规律

#include <cstdio>  
#include <cstring>  
#include <cmath>  
#include <cstdlib>  
#include <algorithm>  
#include <queue>  
#include <stack> 
#define INF 0x3f3f3f3f  
#define eps 1e-8   
#define Si(a) scanf("%d", &a)  
#define Sl(a) scanf("%lld", &a)  
#define Sf(a) scanf("%lf", &a)  
#define Ss(a) scanf("%s", a)  
#define Pi(a) printf("%d\n", (a))  
#define Pf(a) printf("%.2lf\n", (a))  
#define Pl(a) printf("%lld\n", (a))  
#define Ps(a) printf("%s\n", (a))  
#define Wi(a) while((a)--)  
#define cle(a, b) memset(a, (b), sizeof(a))  
#define MOD 1000000007  
#define LL long long  
#define PI acos(-1.0) 
using namespace std;
int main()
{
	__int64  x1, x2, y1, y2, x, y;
	while(scanf("%I64d%I64d%I64d%I64d", &x1, &y1, &x2, &y2)!=EOF)
	{
		x = (x2 - x1)>>1;
		y = (y2 - y1)>>1;
		printf("%I64d\n", x*y+(x+1)*(y+1));
	}
	return 0;
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值