D - Make Target 2 Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 425

問題文

2 次元座標平面があり、座標が (x, y) である格子点は \max(|x|, |y|) が偶数のとき黒、奇数のとき白で塗られています。

L \leq x \leq R かつ D \leq y \leq U を満たす整数の組 (x, y) のうち、座標 (x, y) が黒く塗られているものの個数を求めてください。

制約

  • -10^6 \leq L \leq R \leq 10^6
  • -10^6 \leq D \leq U \leq 10^6
  • 入力される値はすべて整数

入力

入力は以下の形式で標準入力から与えられる。

L R D U

出力

答えを出力せよ。


入力例 1

-4 3 1 3

出力例 1

10

上の図のように、求める答えは 10 となります。


入力例 2

-14 14 -14 14

出力例 2

449

Score : 425 points

Problem Statement

There is a two-dimensional coordinate plane. A lattice point with coordinates (x, y) is painted black if \max(|x|, |y|) is even, and white if it is odd.

Among the pairs of integers (x, y) satisfying L \leq x \leq R and D \leq y \leq U, find the number of those for which the point (x, y) is painted black.

Constraints

  • -10^6 \leq L \leq R \leq 10^6
  • -10^6 \leq D \leq U \leq 10^6
  • All input values are integers.

Input

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

L R D U

Output

Output the answer.


Sample Input 1

-4 3 1 3

Sample Output 1

10

As shown in the figure above, the answer is 10.


Sample Input 2

-14 14 -14 14

Sample Output 2

449