Triangular Frame
InterviewTime limit2sMemory limit1024 MB
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 , , and . Then move the sides of this triangle inward by a distance (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 , , and width 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 , , , (): the lengths of the outer sides of the frame and its width, respectively. It is guaranteed that a triangle with sides , , and exists, and that the triangle contains a point whose distance to the nearest side is strictly greater than .
Output
Print the area of the frame to the output file with precision of at least .