RugSizes
SRM 304 · 2006-05-27 · by dgoodman
Problem Statement
Create a class RugSizes the contains a method rugCount that is given the desired area and returns the number of different ways in which we can choose a rug size that will cover that exact area. Do not count the same size twice -- a 6 x 9 rug and a 9 x 6 rug should be counted as one choice.
Constraints
- area will be between 1 and 100,000, inclusive.
4 Returns: 2
The choices are 1 x 4 (or equivalently 4 x 1) and 2 x 2.
8 Returns: 1
Only 1 x 8 is available. Note that 2 x 4 has the desired area, but is not available since its width and length differ and are both even numbers.
30 Returns: 4
100000 Returns: 6
98415 Returns: 10
Submissions are judged against all 89 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class RugSizes with a public method int rugCount(int area) · 89 test cases · 2 s / 256 MB per case