#abc354d. D - AtCoder Wallpaper
D - AtCoder Wallpaper
Score : points
问题陈述
AtCoder的壁纸图案可以在平面上表示如下:
- 平面被以下三种类型的线分割:
- (其中是整数)
- (其中是偶数)
- (其中是偶数)
- 每个区域被涂成黑色或白色。沿着这些线相邻的任意两个区域颜色不同。
- 包含的区域被涂成黑色。
下面的图示展示了图案的一部分。
给定整数。考虑一个矩形,其边与轴和轴平行,其左下角顶点在,右上角顶点在。计算这个矩形内涂成黑色的区域的面积,并打印出该面积的两倍。
可以证明输出值将是一个整数。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
The pattern of AtCoder's wallpaper can be represented on the -plane as follows:
- The plane is divided by the following three types of lines:
- (where is an integer)
- (where is an even number)
- (where 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 is painted black.
The following figure shows a part of the pattern.
You are given integers . Consider a rectangle whose sides are parallel to the - and -axes, with its bottom-left vertex at and its top-right vertex at . 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
- and .
- All input values are integers.
Input
The input is given from Standard Input in the following format:
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 , so print twice that value: .
Sample Input 2
-1 -2 1 3
Sample Output 2
11
The area is , 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.