This page is still under construction.

Parts of this page are still being built. What you see may change.

Triangular Frame

Interview

Time limit2sMemory limit1024 MB

Summary
Given a triangle with sides a, b, c and a frame width d, find the area of the triangular frame left after cutting out the inner triangle formed by moving each side inward by d.
Level

Medium5 of 10

Topics
Geometry, Math, Implementation, Brute force
Solved
No attempts yet

Problem

Paintings by abstract artists are quite unusual. They often show objects that make no sense at all. One famous abstract artist decided to make his paintings more original in the following way. Instead of the rectangular frames usually used for paintings, he decided to use triangular ones at his upcoming exhibition.

But things were not so simple. The artist made a frame, put a painting in it, and realized something was wrong. The frame came out too wide, and the painting did not look nearly as bright as he had expected.

After some thought, the artist realized that how well a frame <> a painting is determined by the frame's area. He also realized that frames should not be made by hand but bought from a special shop. Looking at the shop's price list, he saw that each frame had its outer side lengths and its width listed.

Let us explain in more detail what a triangular frame looks like. It is made as follows: take a mahogany board shaped like a triangle with sides aa, bb, and cc. Then move the sides of this triangle inward by a distance dd (measured along the perpendicular to the corresponding side). On the intersection points of the <> sides, build a small triangle and cut it out of the original one. An example of a frame with sides a=6a=6, b=8b=8, c=10c=10 and width d=1d=1 is shown in the figure.

Help the artist compute the area of the frame from the data in the price list.

Input

The input file contains four integers aa, bb, cc, dd (1≤a,b,c,d≤10001 \le a, b, c, d \le 1000): the lengths of the outer sides of the frame and its width, respectively. It is guaranteed that a triangle with sides aa, bb, and cc exists, and that the triangle contains a point whose distance to the nearest side is strictly greater than dd.

Output

Print the area of the frame to the output file with precision of at least 10−510^{-5}.

Examples1

  1. Example 1

    Input
    6 8 10 1
    
    Expected output
    18.00000