Statistics

Problem Statement for "RectangleDivision"

Problem Statement

Consider an a by b rectangle, composed of a*b unit squares. Your task is to count the number of ways in which this rectangle can be divided into two contiguous sections, each consisting of 1 or more unit squares. Each section must contain at least 1 square on the edge of the rectangle. A section is contiguous if each square in the section is connected to each other square in the section via a path of horizontally or vertically adjacent squares that are all within the section.

Definition

Class:
RectangleDivision
Method:
count
Parameters:
int, int
Returns:
int
Method signature:
int count(int a, int b)
(be sure your method is public)

Constraints

  • a will be between 1 and 6, inclusive.
  • b will be between 2 and 6, inclusive.

Examples

  1. 1

    3

    Returns: 2

    There are two different ways to split up this rectangle, where '#' represents one section, and '.' the other: ##. #..

  2. 3

    2

    Returns: 15

    Here are the 15 ways: #. .# .. .. #. .# .. .. .. .. .. .. #. .# #. .# .. .. #. .# .. .. #. .# ## .. ## ## ## ## #. .. .. #. .# #. .# #. .. ## ## ## .. .. #.

  3. 1

    2

    Returns: 1

  4. 1

    3

    Returns: 2

  5. 1

    4

    Returns: 3

  6. 1

    5

    Returns: 4

  7. 1

    6

    Returns: 5

  8. 2

    2

    Returns: 6

  9. 2

    3

    Returns: 15

  10. 2

    4

    Returns: 28

  11. 2

    5

    Returns: 45

  12. 2

    6

    Returns: 66

  13. 3

    2

    Returns: 15

  14. 3

    3

    Returns: 52

  15. 3

    4

    Returns: 143

  16. 3

    5

    Returns: 350

  17. 3

    6

    Returns: 799

  18. 4

    2

    Returns: 28

  19. 4

    3

    Returns: 143

  20. 4

    4

    Returns: 614

  21. 4

    5

    Returns: 2431

  22. 4

    6

    Returns: 9184

  23. 5

    2

    Returns: 45

  24. 5

    3

    Returns: 350

  25. 5

    4

    Returns: 2431

  26. 5

    5

    Returns: 16000

  27. 5

    6

    Returns: 102147

  28. 6

    2

    Returns: 66

  29. 6

    3

    Returns: 799

  30. 6

    4

    Returns: 9184

  31. 6

    5

    Returns: 102147

  32. 6

    6

    Returns: 1114394


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: