TLE '16 Contest 6 (Mock CCC) S2 - Paper Stapling


Submit solution


Points:10 (partial)
Time limit:2.0s
Memory limit:256M

Problem type

William takes the first page of the CCC (top image) and turns it over (bottom image). Note the missing corner in the top left of the page, caused by the stapling.

The top computer scientists in Canada have just started the Canadian Computing Cancer (CCC), but Jason and William experience a huge problem. As it turns out, the CCC booklets are so poorly stapled that some words on the top left corner of the page cannot be read. Important pieces of info are cut off due to the stapling, such as the name of the problem's protagonist. The CCC cannot provide a PDF version of the problems because those who start late would have an unfair advantage.

Due to this issue, William measures the endpoints of the staples to be at 2 distinct points (x_1, y_1) and (x_2, y_2) where (0,0) is at the top left corner of the contest package. The x-coordinate increases infinitely as one moves right, and the y-coordinate increases infinitely as one moves down. In order to start the contest, he folds over the first page and makes a crease in a way that maximizes the amount of legible space on the second page. Jason looks at the page and notices that the missing region of the paper forms a right-angled triangle.

What area of paper is left illegible on William's page?

Input Specification

The first line will contain two space-separated integers x_1 and y_1 (1 \le x_1, y_1 \le 10^6).

The second line will contain two space-separated integers x_2 and y_2 (1 \le x_2, y_2 \le 10^6).

The coordinates are distinct points, i.e., (x_1, y_1) \ne (x_2, y_2).

For 3 of the 15 points, all coordinates will not exceed 2.

For an additional 3 of the 15 points, x_1 < x_2 and y_1 < y_2.

Output Specification

Print out the area of paper missing from William's page. An absolute or relative error of 10^{-6} will be considered correct.

Sample Input 1

6 1
1 5

Sample Output 1

21.025000000

Sample Input 2

1 1
3 7

Sample Output 2

42.000000000

Comments

There are no comments at the moment.