Problem Statement
John and Brus are building towers using toy bricks. They have two types of bricks: red and blue ones. The number of red bricks they have is redCount and each of them has a height of redHeight. The number of blue bricks they have is blueCount and each of them has a height of blueHeight.
A tower is built by placing bricks one atop another. A brick can be placed either on the ground, or on a brick of a different color. (I.e., you are not allowed to put two bricks of the same color immediately on one another.) A tower has to consist of at least one brick. The height of a tower is the sum of all heights of bricks that form the tower. Two towers are considered to be different if they have different heights. (Two towers of the same height are considered the same, even if they differ in the number and colors of bricks that form them.)
You are given the
Definition
- Class:
- TheBrickTowerEasyDivTwo
- Method:
- find
- Parameters:
- int, int, int, int
- Returns:
- int
- Method signature:
- int find(int redCount, int redHeight, int blueCount, int blueHeight)
- (be sure your method is public)
Constraints
- redCount will be between 1 and 47, inclusive.
- redHeight will be between 1 and 47, inclusive.
- blueCount will be between 1 and 47, inclusive.
- blueHeight will be between 1 and 47, inclusive.
Examples
1
2
3
4
Returns: 4
John and Brus have 1 red brick of height 2 and 3 blue bricks of height 4. Using these bricks, it's possible to build 4 towers: red (height 2); blue (height 4); red, blue (height 6); blue, red, blue (height 10).
4
4
4
7
Returns: 12
7
7
4
4
Returns: 13
47
47
47
47
Returns: 94
1
1
1
1
Returns: 2
1
41
1
1
Returns: 3
1
4
2
4
Returns: 3
1
1
2
1
Returns: 3
1
3
3
3
Returns: 3
1
38
3
1
Returns: 4
2
34
1
34
Returns: 3
2
14
1
4
Returns: 4
2
4
2
4
Returns: 4
2
33
2
46
Returns: 6
2
26
3
26
Returns: 5
2
40
3
1
Returns: 7
3
8
1
8
Returns: 3
3
43
1
46
Returns: 4
3
47
2
47
Returns: 5
3
3
2
41
Returns: 7
3
35
3
35
Returns: 6
3
47
3
11
Returns: 9
47
24
47
8
Returns: 141
1
13
1
1
Returns: 3
8
46
9
6
Returns: 25
47
38
47
38
Returns: 94
45
10
45
4
Returns: 135
34
5
33
5
Returns: 67
31
45
30
45
Returns: 61
34
21
33
47
Returns: 100
10
47
47
47
Returns: 21
2
47
2
47
Returns: 4
1
1
2
47
Returns: 4
1
47
46
1
Returns: 4
32
4
31
4
Returns: 63
47
45
40
3
Returns: 121
3
46
4
46
Returns: 7
18
16
47
1
Returns: 55
47
46
31
46
Returns: 63
22
47
21
47
Returns: 43
35
46
1
46
Returns: 3
2
1
3
1
Returns: 5
42
47
19
47
Returns: 39
14
2
2
2
Returns: 5
37
1
4
1
Returns: 9
39
2
2
2
Returns: 5
5
10
6
9
Returns: 16
20
1
20
1
Returns: 40
47
47
46
46
Returns: 139
46
44
26
47
Returns: 79
1
2
1
2
Returns: 2
1
3
2
4
Returns: 4
40
2
2
2
Returns: 5
4
5
2
5
Returns: 5
1
4
3
4
Returns: 3
3
4
4
4
Returns: 7
2
2
1
2
Returns: 3
7
1
2
1
Returns: 5
10
10
9
10
Returns: 19
2
1
6
1
Returns: 5
10
10
1
10
Returns: 3
1
5
10
5
Returns: 3
3
5
5
5
Returns: 7
1
1
10
1
Returns: 3
3
1
2
1
Returns: 5
1
2
2
2
Returns: 3
5
4
3
4
Returns: 7
1
47
47
47
Returns: 3
2
3
4
3
Returns: 5
42
43
47
43
Returns: 85
2
3
4
4
Returns: 7
47
1
1
1
Returns: 3
2
5
40
5
Returns: 5
2
2
3
2
Returns: 5
1
1
1
3
Returns: 3
3
10
4
10
Returns: 7
4
47
8
47
Returns: 9