405689: GYM102035 M Ahmad Jaber Rectangles

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

M. Ahmad Jaber Rectanglestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Ahmad has two rectangles, both of them are above $$$x-axis$$$ and the height of each one is $$$h$$$ $$$(1 \leq h \leq 10^{9})$$$.

The first rectangle's sides are $$$(x_1,0)$$$ $$$(x_2,0)$$$ $$$(x_1,h)$$$ $$$(x_2,h)$$$

The second rectangle's sides are $$$(x_3,0)$$$ $$$(x_4,0)$$$ $$$(x_3,h)$$$ $$$(x_4,h)$$$

Ahmad wants to know what is the area of the intersection between these two rectangles.

Input

The first and the only line of input contains 5 integers $$$x_1$$$,$$$x_2$$$,$$$x_3$$$,$$$x_4$$$ and $$$h$$$

$$$(1 \leq x_1 < x_2 \leq 10^{9})$$$ $$$(1 \leq x_3 < x_4 \leq 10^{9})$$$ $$$(1 \leq h \leq 10^{9})$$$.

Output

Print the area of intersection.

ExampleInput
1 4 2 3 5
Output
5

Source/Category

加入题单

上一题 下一题 算法标签: