PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000379. Tấm thảm bị ố (Stained Carpet)

    ID: 3507 Loại: Thông thường 2000ms 256MiB Tried: 0 Đã chấp nhận: 0 Độ khó: 1 Đăng bởi: Nhãn>Binary search on answerComputational geometry basicsPoints and linesFloating point arithmeticInteger overflow
HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Tấm thảm bị ố (Stained Carpet)

Stained Carpet

Source: Kattis

Version: Phuoc Hung OJ Extended

Problem Statement

ACM manufactures carpets in the shape of equilateral triangles. A manufacturing defect has made some carpets susceptible to stains. ACM will replace a stained carpet if it is one of these carpets.

Let AA, BB, and CC be the vertices of the carpet and let SS be the location of a stain. The point SS may lie inside the equilateral triangle or on its boundary. The customer reports three distances a=SAa=SA, b=SBb=SB, and c=SCc=SC.

The stain and its distances to the three vertices

Determine whether an equilateral carpet can have the reported distances. If so, compute its area. Otherwise, report that no suitable carpet exists.

To account for rounding in the reported decimal measurements, this version uses the following rule. First consider the distances exactly as entered. If no carpet exists, one may decrease exactly one largest distance by at most 5⋅10−75\cdot10^{-7}, keeping the other two unchanged. If this makes a carpet possible, use the smallest such decrease to compute its area. If a carpet is still impossible, the result is -1.000.

Input

One line contains three positive decimal numbers aa, bb, and cc, respectively denoting the distances from the stain to vertices AA, BB, and CC. Each number is written in ordinary decimal notation with an integer part and optionally one to six digits after a decimal point; scientific notation is not used.

Output

Print the area of the carpet, rounded to exactly three digits after the decimal point. If the value is exactly halfway between two rounded values, choose the larger one. If no carpet exists under the rule above, print -1.000.

Subtasks

  • Subtask 1 (20 points): 10−6≤a,b,c≤10010^{-6}\le a,b,c\le100; each number has at most six digits after the decimal point; a=b=ca=b=c.
  • Subtask 2 (30 points): 10−6≤a,b,c≤10010^{-6}\le a,b,c\le100; each number has at most six digits after the decimal point; at least two distances are equal.
  • Subtask 3 (50 points): 10−6≤a,b,c≤10010^{-6}\le a,b,c\le100; each number has at most six digits after the decimal point.

Example 1

Input

1 1 1.732051

Output

1.732

Explanation

The stain is the midpoint of a side of length 22. Both distances to its endpoints equal 11; the distance to the opposite vertex is the altitude 3≈1.7320508076\sqrt3\approx1.7320508076. The third reported distance exceeds that value by approximately 0.00000019240.0000001924, which is within the permitted adjustment. After adjustment, the area of the equilateral triangle of side 22 is 223/4=32^2\sqrt3/4=\sqrt3. Rounding gives 1.732.

Example 2

Input

1 1 3.0

Output

-1.000

Explanation

Two vertices are one unit from the stain, so the side joining them has length at most 22. For a point inside or on the boundary of an equilateral triangle of side at most 22, its distance to any vertex cannot exceed 22. The third reported distance is 33, and the permitted adjustment is too small to satisfy this condition. Thus no carpet exists.

Example 3

Input

1.732051 1.732051 1.732051

Output

3.897

Explanation

All three distances are equal, so the stain is the centre of the equilateral triangle. If the circumradius is r=1.732051r=1.732051, the side is r3r\sqrt3. The area is 3r23/43r^2\sqrt3/4, approximately 3.8971153.897115. Rounding gives 3.897.