Statistics

Problem Statement for "TheBrickTowerEasyDivOne"

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:
TheBrickTowerEasyDivOne
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 474,747,474, inclusive.
  • redHeight will be between 1 and 474,747,474, inclusive.
  • blueCount will be between 1 and 474,747,474, inclusive.
  • blueHeight will be between 1 and 474,747,474, 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. 474747474

    474747474

    474747474

    292633855

    Returns: 1424242422

  49. 474747474

    474747474

    474747474

    474747474

    Returns: 949494948

  50. 474747474

    474747468

    474746558

    474747468

    Returns: 949493117

  51. 474627584

    474747437

    474321382

    504

    Returns: 1422964147

  52. 474747473

    474273670

    466712388

    474273670

    Returns: 933424777

  53. 5381

    474393051

    5382

    474393051

    Returns: 10763

  54. 33222208

    55274

    33222209

    41280768

    Returns: 99666625

  55. 47075863

    181543779

    47075864

    993924

    Returns: 141227590

  56. 470418661

    454

    399796762

    454

    Returns: 799593525

  57. 33241

    421687360

    74544080

    473675028

    Returns: 99724

  58. 474733002

    115658936

    474733001

    115658936

    Returns: 949466003

  59. 92287

    1

    92286

    465155160

    Returns: 276859

  60. 118256

    474747470

    118256

    474747470

    Returns: 236512

  61. 1

    474747472

    9943413

    474747472

    Returns: 3

  62. 49344750

    288525

    49344749

    62807079

    Returns: 148034248

  63. 474631371

    1160014

    474631372

    263540944

    Returns: 1423894114

  64. 415038707

    1329630

    415038708

    1329630

    Returns: 830077415

  65. 920505

    1

    920504

    1

    Returns: 1841009

  66. 218113

    474076373

    195671916

    474076373

    Returns: 436227

  67. 474743982

    474721201

    474744825

    474721201

    Returns: 949487965

  68. 474742218

    5

    474747474

    5

    Returns: 949484437

  69. 474746972

    474551967

    474746971

    474551967

    Returns: 949493943

  70. 474747362

    5

    474747361

    108358890

    Returns: 1424242084

  71. 396305893

    1

    4263546

    1

    Returns: 8527093

  72. 402

    474746117

    402

    474746117

    Returns: 804

  73. 1268

    282291

    470776704

    1

    Returns: 3805

  74. 458978111

    474747339

    458978112

    61

    Returns: 1376934334

  75. 1

    3

    2

    3

    Returns: 3

  76. 1

    1

    1000

    1

    Returns: 3

  77. 444444444

    444444444

    444444444

    444444444

    Returns: 888888888

  78. 2

    1

    4

    1

    Returns: 5

  79. 5

    1

    6

    1

    Returns: 11

  80. 474747474

    474747474

    474747474

    474747473

    Returns: 1424242422

  81. 1

    4

    3

    4

    Returns: 3

  82. 1

    1

    100

    1

    Returns: 3

  83. 1000

    10

    10

    10

    Returns: 21

  84. 47

    47

    48

    47

    Returns: 95

  85. 5

    3

    8

    3

    Returns: 11

  86. 1

    5

    4

    5

    Returns: 3

  87. 1

    2

    3

    2

    Returns: 3

  88. 4

    10

    10

    10

    Returns: 9

  89. 474747474

    30

    474747474

    50

    Returns: 1424242422

  90. 9

    9

    1

    9

    Returns: 3

  91. 4

    4

    7

    4

    Returns: 9

  92. 5

    2

    1

    2

    Returns: 3

  93. 10

    1

    5

    1

    Returns: 11

  94. 17

    11

    13

    11

    Returns: 27

  95. 9

    5

    5

    5

    Returns: 11

  96. 10

    5

    8

    5

    Returns: 17

  97. 100

    1

    1

    1

    Returns: 3

  98. 84

    47

    92

    47

    Returns: 169

  99. 4

    5

    4

    5

    Returns: 8

  100. 1000

    6

    10

    4

    Returns: 31

  101. 10000

    10000

    10000

    10000

    Returns: 20000

  102. 474747470

    474747439

    474747420

    474747433

    Returns: 1424242261

  103. 100

    10

    1

    10

    Returns: 3

  104. 9

    11

    13

    11

    Returns: 19

  105. 5

    1

    3

    1

    Returns: 7

  106. 1

    1

    5

    1

    Returns: 3

  107. 1

    1

    10

    1

    Returns: 3

  108. 474747474

    474747474

    474747472

    474747474

    Returns: 949494945

  109. 100

    100

    1

    2

    Returns: 4

  110. 1

    3

    10

    3

    Returns: 3

  111. 1

    100

    1000

    100

    Returns: 3

  112. 10

    5

    9

    9

    Returns: 28

  113. 3

    4

    4

    4

    Returns: 7

  114. 1

    1

    999

    1

    Returns: 3

  115. 3

    3

    10

    3

    Returns: 7

  116. 10000

    1

    2

    1

    Returns: 5

  117. 20

    7

    17

    7

    Returns: 35

  118. 474747474

    1

    474747474

    2

    Returns: 1424242422

  119. 470000000

    470000000

    470000000

    470000000

    Returns: 940000000

  120. 474747474

    474747474

    474747473

    474747474

    Returns: 949494947

  121. 4

    2

    3

    2

    Returns: 7

  122. 474747412

    414747412

    474741412

    470747412

    Returns: 1424224237

  123. 474747474

    474747473

    474747472

    474747471

    Returns: 1424242417

  124. 4

    4

    5

    4

    Returns: 9

  125. 5

    474747474

    2

    474747474

    Returns: 5

  126. 2

    2

    1

    2

    Returns: 3

  127. 5

    1

    1

    1

    Returns: 3


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: