Statistics

Problem Statement for "TheBrickTowerHardDivTwo"

Problem Statement

John and Brus are building towers using toy bricks. They have an unlimited supply of bricks of C different colors. Each brick is a 1x1x1 cube. A tower of height X is a 2x2xX rectangular prism, built using 4X bricks.

John and Brus want their towers to look nice. A tower is nice if it has the following two properties:

  • There are at most K pairs of neighboring bricks with the same color. (Two bricks are neighboring if they share a common side.)
  • The height of the tower is between 1 and H, inclusive.

You are given the ints C, K, and H. Return the number of nice towers, modulo 1,234,567,891.

Definition

Class:
TheBrickTowerHardDivTwo
Method:
find
Parameters:
int, int, int
Returns:
int
Method signature:
int find(int C, int K, int H)
(be sure your method is public)

Constraints

  • C will be between 1 and 4, inclusive.
  • K will be between 0 and 7, inclusive.
  • H will be between 1 and 47, inclusive.

Examples

  1. 2

    0

    2

    Returns: 4

    No two neighboring bricks may share the same color. As we only have two colors, the entire tower must be colored like a chessboard. There are two such towers of height 1, and two of height 2.

  2. 1

    7

    19

    Returns: 1

    Only one tower of height 1 is acceptable here.

  3. 2

    3

    1

    Returns: 14

    There are 16 possible towers of height 1. If all bricks share the same color, the tower is not nice. There are two such towers. Each of the remaining 14 towers is nice.

  4. 4

    7

    47

    Returns: 1008981254

  5. 1

    3

    19

    Returns: 0

  6. 3

    6

    26

    Returns: 63744861

  7. 1

    5

    15

    Returns: 1

  8. 4

    2

    42

    Returns: 546398371

  9. 1

    0

    32

    Returns: 0

  10. 4

    2

    19

    Returns: 948231878

  11. 4

    5

    12

    Returns: 867619386

  12. 1

    3

    43

    Returns: 0

  13. 3

    6

    15

    Returns: 198242641

  14. 1

    5

    33

    Returns: 1

  15. 1

    3

    11

    Returns: 0

  16. 2

    6

    24

    Returns: 16094

  17. 1

    4

    15

    Returns: 1

  18. 1

    4

    43

    Returns: 1

  19. 3

    1

    10

    Returns: 1220741998

  20. 2

    4

    39

    Returns: 8426

  21. 4

    6

    45

    Returns: 675895602

  22. 3

    4

    44

    Returns: 1175696211

  23. 4

    6

    46

    Returns: 133331749

  24. 4

    5

    44

    Returns: 485822408

  25. 4

    2

    4

    Returns: 80001192

  26. 4

    0

    8

    Returns: 978491432

  27. 4

    2

    9

    Returns: 752462956

  28. 4

    5

    1

    Returns: 256

  29. 4

    3

    17

    Returns: 577534162

  30. 4

    6

    6

    Returns: 941725416

  31. 4

    7

    47

    Returns: 1008981254

  32. 4

    0

    47

    Returns: 699527058

  33. 4

    0

    10

    Returns: 864059624

  34. 1

    0

    23

    Returns: 0

  35. 4

    0

    12

    Returns: 294638799

  36. 4

    0

    21

    Returns: 160339243

  37. 1

    0

    19

    Returns: 0

  38. 3

    0

    26

    Returns: 1122838812

  39. 1

    0

    29

    Returns: 0

  40. 1

    0

    34

    Returns: 0

  41. 2

    2

    8

    Returns: 28

  42. 1

    0

    23

    Returns: 0

  43. 2

    2

    6

    Returns: 24

  44. 2

    5

    21

    Returns: 3304

  45. 1

    3

    7

    Returns: 0

  46. 1

    6

    4

    Returns: 1

  47. 1

    5

    7

    Returns: 1

  48. 4

    6

    47

    Returns: 240414241

  49. 4

    5

    47

    Returns: 734623669

  50. 4

    7

    46

    Returns: 1064072547


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: