TheBrickTowerEasyDivTwo
SRM 554 · 2012-06-05 · by Vasyl[alphacom]
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
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.
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
Submissions are judged against all 77 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class TheBrickTowerEasyDivTwo with a public method int find(int redCount, int redHeight, int blueCount, int blueHeight) · 77 test cases · 2 s / 256 MB per case