BiggestRectangleEasy
SRM 318 · 2006-08-29 · by Andrew_Lazarev
Problem Statement
Little Josh has found several sticks that are each 1 inch long. He wants to form a rectangle with the biggest possible area, using these sticks as the perimeter. He is allowed to glue sticks together, but he is not allowed to break a single stick into multiple shorter sticks.
For example, if Josh has 11 sticks, he can create a 2 x 3 rectangle using 10 sticks. This rectangle has an area of 6 square inches, which is the biggest area that can be achieved in this case.
You will be given an
Constraints
- N will be between 4 and 10000, inclusive.
11 Returns: 6
The example from the problem statement.
5 Returns: 1
The only rectangle that can be created is a square with 1 inch side.
64 Returns: 256
Josh can create a square with the 16 inches side.
753 Returns: 35344
7254 Returns: 3288782
Submissions are judged against all 75 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class BiggestRectangleEasy with a public method int findArea(int N) · 75 test cases · 2 s / 256 MB per case