Statistics

Problem Statement for "IsoscelesTriangulations"

Problem Statement

Let's consider a regular polygon on the plane with n vertices, numbered from 0 to n-1, inclusive. The polygon's n-3 diagonals are called a triangulation if no two diagonals intersect at a point strictly inside the polygon. Two triangulations A and B are considered to be distinct if there are two vertices i and j such that A contains the diagonal between vertices i and j, and B doesn't contain this diagonal.

It's not hard to see that every triangulation breaks the polygon into n-2 triangles. The triangulation is called k-isosceles, if there are exactly k isosceles triangles among them. Given ints n and k, compute the number of distinct k-isosceles triangulations of a regular polygon with n vertices. Return the result modulo 123456789.

Definition

Class:
IsoscelesTriangulations
Method:
getCount
Parameters:
int, int
Returns:
int
Method signature:
int getCount(int n, int k)
(be sure your method is public)

Notes

  • A triangle is called isosceles if it has at least 2 sides with equal length.
  • A regular polygon is a polygon which is equiangular (all angles are congruent) and equilateral (all sides have the same length).
  • A diagonal is a line joining two nonadjacent vertices of a polygon.

Constraints

  • n will be between 3 and 50, inclusive.
  • k will be between 0 and n-2, inclusive.

Examples

  1. 4

    2

    Returns: 2

    We can have a diagonal between vertices 0 and 2 or between vertices 1 and 3. In both cases, there are 2 isosceles triangles.

  2. 3

    0

    Returns: 0

    The only triangulation of an equilateral triangle contains no diagonals and 1 isosceles triangle (the polygon itself).

  3. 5

    3

    Returns: 5

    A regular pentagon has 5 triangulations. Each of them is obtained by connecting one selected vertex with the two others that are not its neighbors, so each triangulation is 3-isosceles.

  4. 6

    2

    Returns: 12

    All 2-isosceles triangles of a regular hexagon are shown in the picture below. All isosceles triangles in each triangulation are colored purple.

  5. 10

    8

    Returns: 10

    All 8-isosceles triangulations of a regular 10-gon are shown in the picture below. All triangles in each triangulation are isosceles.

  6. 3

    1

    Returns: 1

  7. 4

    0

    Returns: 0

  8. 4

    1

    Returns: 0

  9. 5

    0

    Returns: 0

  10. 5

    1

    Returns: 0

  11. 5

    2

    Returns: 0

  12. 6

    4

    Returns: 2

  13. 7

    3

    Returns: 28

  14. 7

    4

    Returns: 14

  15. 8

    6

    Returns: 4

  16. 8

    4

    Returns: 64

  17. 8

    2

    Returns: 64

  18. 9

    7

    Returns: 9

  19. 9

    5

    Returns: 108

  20. 9

    4

    Returns: 24

  21. 9

    3

    Returns: 288

  22. 10

    6

    Returns: 140

  23. 10

    5

    Returns: 80

  24. 10

    4

    Returns: 560

  25. 10

    3

    Returns: 320

  26. 10

    2

    Returns: 320

  27. 36

    31

    Returns: 14496

  28. 14

    4

    Returns: 60928

  29. 34

    4

    Returns: 21406679

  30. 47

    11

    Returns: 105275978

  31. 23

    5

    Returns: 106887772

  32. 26

    8

    Returns: 83920238

  33. 16

    4

    Returns: 638976

  34. 37

    9

    Returns: 1198520

  35. 25

    7

    Returns: 65975697

  36. 12

    7

    Returns: 480

  37. 37

    26

    Returns: 65855403

  38. 29

    9

    Returns: 74024031

  39. 19

    3

    Returns: 1867776

  40. 22

    17

    Returns: 3696

  41. 27

    22

    Returns: 2232

  42. 13

    2

    Returns: 0

  43. 31

    1

    Returns: 0

  44. 12

    9

    Returns: 0

  45. 35

    33

    Returns: 0

  46. 35

    0

    Returns: 0

  47. 50

    9

    Returns: 58394758

  48. 50

    47

    Returns: 100

  49. 50

    21

    Returns: 31719829

  50. 50

    39

    Returns: 92087776

  51. 50

    36

    Returns: 15420199

  52. 50

    48

    Returns: 0

  53. 50

    46

    Returns: 1000

  54. 50

    45

    Returns: 16000

  55. 50

    0

    Returns: 0

  56. 50

    1

    Returns: 0

  57. 50

    2

    Returns: 101931970

  58. 50

    3

    Returns: 114751022

  59. 50

    44

    Returns: 226000

  60. 50

    4

    Returns: 11410498

  61. 50

    10

    Returns: 112698825

  62. 50

    7

    Returns: 20336526

  63. 49

    23

    Returns: 62241972

  64. 50

    20

    Returns: 28775584

  65. 50

    25

    Returns: 107780782


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: