MinimalTriangle
SRM 547 · 2011-11-22 · by sdya
SRM 547 · 2011-11-22 · by sdya · Geometry
Problem Statement
Problem Statement
You are given a int length.
We have a regular hexagon: a polygon with six sides, in which all internal angles have 120 degrees and length is the length of each side.
We are going to draw three non-intersecting diagonals in some way.
These will divide the hexagon into four triangles.
We will then compute their areas, take a piece of paper and write down the smallest of those four areas.
Compute and return the largest number we can obtain on our piece of paper (by choosing which diagonals to draw).
Notes
- Your return value must have a relative or an absolute error of less than 1e-9.
Constraints
- length will be between 1 and 1,000,000 (10^6), inclusive.
Examples
0)
5 Returns: 10.825317547305485
1)
10 Returns: 43.30127018922194
2)
100000 Returns: 4.330127018922194E9
3)
100 Returns: 4330.127018922194
4)
1000 Returns: 433012.70189221937
Submissions are judged against all 36 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class MinimalTriangle with a public method double maximalArea(int length) · 36 test cases · 2 s / 256 MB per case