Smallest polygon from sticks

Given counts of four stick orientations (horizontal, vertical, and two diagonals), arrange all of them as the sides of a simple lattice polygon and minimize its area.

Medium7GeometryGreedyMathImplementationNo attempts yetTime limit1sMemory limit1024 MB

Problem

Mirko read about Pick's theorem. Draw a polygon in the coordinate plane whose vertices are all lattice points, let AA be its area, let ii be the number of lattice points strictly inside the polygon, and let pp be the number of lattice points on its edges. The vertices count as lattice points on the edges. Then the following always holds.

A=i+p21A = i + \frac{p}{2} - 1

Figure 1: this polygon has A=8A = 8, i=4i = 4, p=10p = 10.

To check the theorem, Mirko decided to build a polygon out of magnetic sticks on his magnetic board. During the night the sticks slid to the bottom of the board because of gravity. Mirko collected the following sticks.

  • aa horizontal sticks of length 11
  • bb vertical sticks of length 11
  • cc diagonal sticks of length 2\sqrt{2} that form a 4545^\circ angle with the positive direction of the xx-axis
  • dd diagonal sticks of length 2\sqrt{2} that form a 135135^\circ angle with the positive direction of the xx-axis

Figure 2: the sticks Mirko collected.

Mirko can move a stick anywhere on the board, but he cannot rotate it. He has to use every collected stick in one polygon, and each stick becomes one side of that polygon. All vertices of the polygon are lattice points, and two neighbouring sides may be parallel. The polygon must not touch or intersect itself.

Find the smallest area a polygon built this way can have.

Input

The first line contains four integers aa, bb, cc, dd, separated by spaces.

Output

Print the smallest area of a polygon that uses all of the sticks, with exactly one digit after the decimal point. The smallest area is always a multiple of 0.50.5, so this format is exact.

Constraints

  • 0a,b,c,d1000 \le a, b, c, d \le 100
  • a+b+c+d3a + b + c + d \ge 3
  • The given sticks can build at least one polygon that meets the conditions.