Connection Status:
Competition Arena > BiggestRectangleEasy
SRM 318 · 2006-08-29 · by Andrew_Lazarev · Geometry
Class Name: BiggestRectangleEasy
Return Type: int
Method Name: findArea
Arg Types: (int)
Problem Statement

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 int N, and you must return the maximal area (in square inches) of a rectangle that can be created using N or less sticks.

Constraints

  • N will be between 4 and 10000, inclusive.
Examples
0)
11
Returns: 6

The example from the problem statement.

1)
5
Returns: 1

The only rectangle that can be created is a square with 1 inch side.

2)
64
Returns: 256

Josh can create a square with the 16 inches side.

3)
753
Returns: 35344
4)
7254
Returns: 3288782

Submissions are judged against all 75 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

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

Submitting as anonymous