CardboardBoxes
SRM 783 · 2020-03-30 · by misof
Problem Statement
This problem is about a special type of cardboard boxes. When assembled, these boxes have three dimensions: length, width, and height. All three dimensions must be positive integers. Length and width are interchangable: a (length,width,height) box is the same as a (width,length,height) box.
A cardboard box consists of 12 connected pieces of cardboard. The shape of each piece is a rectangle.
Four of these pieces are simply the sides of the box. If we only had these four pieces, we would have a box that is missing the top and the bottom. We will call this shape an open box.
The next four pieces are flaps on the top of the box. Each flap is connected to one of the four edges of the open box. Thus, one dimension of each flap is fixed. All four flaps have the same second dimension, and this dimension is as small as possible given that together the four flaps can completely cover the top of the box. For example, if your box is 50 cm long and 21 cm wide, each of the top flaps will have dimensions (the length of the edge it is attached to, times 10.5 cm).
The last four pieces are flaps on the bottom. These look the same as the flaps on the top.
Given the total surface area S of the cardboard box, count all possible dimensions it may have.
Notes
- As shown in the statement, only the dimensions of the box itself must be integers. The flaps can have one dimension that is not an integer.
Constraints
- S will be between 1 and 10^13, inclusive.
47 Returns: 0
It should be quite obvious that the surface area of a valid cardboard box cannot be 47.
470 Returns: 6
The six distinct sets of dimensions (in the order width, length, height) that correspond to surface area 470 are listed below: 1 4 46 1 46 4 2 3 45 2 45 3 3 44 2 4 43 1
4700 Returns: 106
1 Returns: 0
2 Returns: 0
Submissions are judged against all 187 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class CardboardBoxes with a public method long long count(long long S) · 187 test cases · 2 s / 256 MB per case