#abc354d. D - AtCoder Wallpaper

D - AtCoder Wallpaper

Score : 450450 points

问题陈述

AtCoder的壁纸图案可以在xyxy平面上表示如下:

  • 平面被以下三种类型的线分割:
    • x=nx = n(其中nn是整数)
    • y=ny = n(其中nn是偶数)
    • x+y=nx + y = n(其中nn是偶数)
  • 每个区域被涂成黑色或白色。沿着这些线相邻的任意两个区域颜色不同。
  • 包含(0.5,0.5)(0.5, 0.5)的区域被涂成黑色。

下面的图示展示了图案的一部分。

给定整数A,B,C,DA, B, C, D。考虑一个矩形,其边与xx轴和yy轴平行,其左下角顶点在(A,B)(A, B),右上角顶点在(C,D)(C, D)。计算这个矩形内涂成黑色的区域的面积,并打印出该面积的两倍。

可以证明输出值将是一个整数。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

The pattern of AtCoder's wallpaper can be represented on the xyxy-plane as follows:

  • The plane is divided by the following three types of lines:
    • x=nx = n (where nn is an integer)
    • y=ny = n (where nn is an even number)
    • x+y=nx + y = n (where nn is an even number)
  • Each region is painted black or white. Any two regions adjacent along one of these lines are painted in different colors.
  • The region containing (0.5,0.5)(0.5, 0.5) is painted black.

The following figure shows a part of the pattern.

You are given integers A,B,C,DA, B, C, D. Consider a rectangle whose sides are parallel to the xx- and yy-axes, with its bottom-left vertex at (A,B)(A, B) and its top-right vertex at (C,D)(C, D). Calculate the area of the regions painted black inside this rectangle, and print twice that area.

It can be proved that the output value will be an integer.

Constraints

  • 109A,B,C,D109-10^9 \leq A, B, C, D \leq 10^9
  • A<CA < C and B<DB < D.
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

AA BB CC DD

Output

Print the answer on a single line.

Sample Input 1

0 0 3 3

Sample Output 1

10

We are to find the area of the black-painted region inside the following square:

The area is 55, so print twice that value: 1010.

Sample Input 2

-1 -2 1 3

Sample Output 2

11

The area is 5.55.5, which is not an integer, but the output value is an integer.

Sample Input 3

-1000000000 -1000000000 1000000000 1000000000

Sample Output 3

4000000000000000000

This is the case with the largest rectangle, where the output still fits into a 64-bit signed integer.