Statistics

Problem Statement for "TheBrickTowerEasyDivTwo"

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 ints redCount, redHeight, blueCount and blueHeight. Return the number of different towers that John and Brus can build.

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. 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).

  2. 4

    4

    4

    7

    Returns: 12

  3. 7

    7

    4

    4

    Returns: 13

  4. 47

    47

    47

    47

    Returns: 94

  5. 1

    1

    1

    1

    Returns: 2

  6. 1

    41

    1

    1

    Returns: 3

  7. 1

    4

    2

    4

    Returns: 3

  8. 1

    1

    2

    1

    Returns: 3

  9. 1

    3

    3

    3

    Returns: 3

  10. 1

    38

    3

    1

    Returns: 4

  11. 2

    34

    1

    34

    Returns: 3

  12. 2

    14

    1

    4

    Returns: 4

  13. 2

    4

    2

    4

    Returns: 4

  14. 2

    33

    2

    46

    Returns: 6

  15. 2

    26

    3

    26

    Returns: 5

  16. 2

    40

    3

    1

    Returns: 7

  17. 3

    8

    1

    8

    Returns: 3

  18. 3

    43

    1

    46

    Returns: 4

  19. 3

    47

    2

    47

    Returns: 5

  20. 3

    3

    2

    41

    Returns: 7

  21. 3

    35

    3

    35

    Returns: 6

  22. 3

    47

    3

    11

    Returns: 9

  23. 47

    24

    47

    8

    Returns: 141

  24. 1

    13

    1

    1

    Returns: 3

  25. 8

    46

    9

    6

    Returns: 25

  26. 47

    38

    47

    38

    Returns: 94

  27. 45

    10

    45

    4

    Returns: 135

  28. 34

    5

    33

    5

    Returns: 67

  29. 31

    45

    30

    45

    Returns: 61

  30. 34

    21

    33

    47

    Returns: 100

  31. 10

    47

    47

    47

    Returns: 21

  32. 2

    47

    2

    47

    Returns: 4

  33. 1

    1

    2

    47

    Returns: 4

  34. 1

    47

    46

    1

    Returns: 4

  35. 32

    4

    31

    4

    Returns: 63

  36. 47

    45

    40

    3

    Returns: 121

  37. 3

    46

    4

    46

    Returns: 7

  38. 18

    16

    47

    1

    Returns: 55

  39. 47

    46

    31

    46

    Returns: 63

  40. 22

    47

    21

    47

    Returns: 43

  41. 35

    46

    1

    46

    Returns: 3

  42. 2

    1

    3

    1

    Returns: 5

  43. 42

    47

    19

    47

    Returns: 39

  44. 14

    2

    2

    2

    Returns: 5

  45. 37

    1

    4

    1

    Returns: 9

  46. 39

    2

    2

    2

    Returns: 5

  47. 5

    10

    6

    9

    Returns: 16

  48. 20

    1

    20

    1

    Returns: 40

  49. 47

    47

    46

    46

    Returns: 139

  50. 46

    44

    26

    47

    Returns: 79

  51. 1

    2

    1

    2

    Returns: 2

  52. 1

    3

    2

    4

    Returns: 4

  53. 40

    2

    2

    2

    Returns: 5

  54. 4

    5

    2

    5

    Returns: 5

  55. 1

    4

    3

    4

    Returns: 3

  56. 3

    4

    4

    4

    Returns: 7

  57. 2

    2

    1

    2

    Returns: 3

  58. 7

    1

    2

    1

    Returns: 5

  59. 10

    10

    9

    10

    Returns: 19

  60. 2

    1

    6

    1

    Returns: 5

  61. 10

    10

    1

    10

    Returns: 3

  62. 1

    5

    10

    5

    Returns: 3

  63. 3

    5

    5

    5

    Returns: 7

  64. 1

    1

    10

    1

    Returns: 3

  65. 3

    1

    2

    1

    Returns: 5

  66. 1

    2

    2

    2

    Returns: 3

  67. 5

    4

    3

    4

    Returns: 7

  68. 1

    47

    47

    47

    Returns: 3

  69. 2

    3

    4

    3

    Returns: 5

  70. 42

    43

    47

    43

    Returns: 85

  71. 2

    3

    4

    4

    Returns: 7

  72. 47

    1

    1

    1

    Returns: 3

  73. 2

    5

    40

    5

    Returns: 5

  74. 2

    2

    3

    2

    Returns: 5

  75. 1

    1

    1

    3

    Returns: 3

  76. 3

    10

    4

    10

    Returns: 7

  77. 4

    47

    8

    47

    Returns: 9


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: