Problem Statement
A set of stairs with two treads would have three risers and would look similar to this picture:
+........ | +---+ | +---+ | ........+
We have the following requirements for a set of stairs:
- all risers must have the same integer height
- all treads must have the same integer width
- each riser must be less than or equal to maxHeight
- each tread must be greater than or equal to minWidth
Create a class Stairs that contains a method designs that takes as input four
Definition
- Class:
- Stairs
- Method:
- designs
- Parameters:
- int, int, int, int
- Returns:
- int
- Method signature:
- int designs(int maxHeight, int minWidth, int totalHeight, int totalWidth)
- (be sure your method is public)
Constraints
- maxHeight, minWidth, totalHeight, and totalWidth will be between 1 and 1000 inclusive
Examples
22
25
100
100
Returns: 1
The only design is to have each riser be 20, each tread be 25.
25
25
60
100
Returns: 2
We could have riser height 12 with tread width 25, or we could have riser height 20, tread width 50. The design with just one tread of width 100 would force each riser to be 30 which exceeds the specified maxHeight, and a design with 6 risers of height 10 would result in treads of width 20 which is smaller than the specified minWidth.
1000
1
600
600
Returns: 6
There are six different designs. The one with the biggest steps has just one tread of size 600, and two risers of size 300. The one with the smallest steps has 24 treads, each of width 25, and its 25 risers each have a height of 24.
359
1
720
720
Returns: 7
360
1
720
720
Returns: 8
355
2
720
719
Returns: 0
22
18
60
48
Returns: 1
10
10
1000
1000
Returns: 0
390
54
324
160
Returns: 2
1000
1000
1000
1000
Returns: 1
1000
2
720
480
Returns: 7
1000
61
720
480
Returns: 5
300
61
720
480
Returns: 4
1
2
3
4
Returns: 1
10
3
30
40
Returns: 3
170
4
960
720
Returns: 3
1
1
1
1
Returns: 0
3
3
9
6
Returns: 1
12
5
24
24
Returns: 3
1
1
2
1
Returns: 1