Statistics

Problem Statement for "Morphling"

Problem Statement

You are given the ints N and K.

Let S be the set of all arrays that have the following properties:
  • The length of the array is exactly N.
  • Each element in the array is an integer between 1 and N, inclusive.
  • Each number occurs in the array at most K times.
Morphing an array A is an operation that consists of three steps:
  1. Choose two distinct integers x and y, each between 1 and N, inclusive.
  2. Change the values of some elements of A: All elements of A that had the value x will now have the value y and vice versa.
  3. Finally, swap two elements of A: the elements with the 1-based indices x and y.
For example, suppose that A = [1,3,3,4]. One possible morphing of this array will look as follows:
  1. We choose x=1 and y=3.
  2. After changing the values in A, we have the array [3,1,1,4].
  3. Then, after the swap we have the final result: the array [1,1,3,4].

Note that if we morph an array that belongs into S, the result will always belong into S as well.

We are interested in a subset T of S with the property that any array in S can be produced from some array in T by a sequence of zero or more morphing operations. Find the smallest possible size of such subset T, and return its size modulo 1,000,000,007.

Definition

Class:
Morphling
Method:
findsz
Parameters:
int, int
Returns:
int
Method signature:
int findsz(int N, int K)
(be sure your method is public)

Constraints

  • N will be between 1 and 100, inclusive.
  • K will be between 1 and min(25, N), inclusive.

Examples

  1. 1

    1

    Returns: 1

    The only valid array is [1]. The subset T must contain this array.

  2. 2

    1

    Returns: 2

    There are two arrays in S: [1,2] and [2,1]. The morphing operation always changes [1,2] into [1,2] and it always changes [2,1] into [2,1]. Therefore we need to include both arrays into T.

  3. 2

    2

    Returns: 3

    There are four arrays in S: [1,2], [2,1], [1,1], [2,2]. The morphing operation allows to transform [1,1] to [2,2], so only one of this should be included into T.

  4. 3

    1

    Returns: 3

  5. 3

    3

    Returns: 7

    Here the set S contains 27 different arrays. Some of these arrays can be produced from other arrays by morphing. The smallest possible subset T with the required property consists of only 7 of these arrays.

  6. 10

    1

    Returns: 42

  7. 48

    18

    Returns: 270440792

  8. 100

    25

    Returns: 796177038

  9. 9

    9

    Returns: 2615

  10. 95

    19

    Returns: 945044826

  11. 50

    3

    Returns: 606683264

  12. 69

    14

    Returns: 15602052

  13. 71

    25

    Returns: 805176177

  14. 93

    22

    Returns: 295332237

  15. 37

    22

    Returns: 387457839

  16. 96

    1

    Returns: 118114304

  17. 14

    14

    Returns: 466199

  18. 30

    3

    Returns: 338273764

  19. 17

    17

    Returns: 10884049

  20. 11

    5

    Returns: 19837

  21. 90

    15

    Returns: 498270418

  22. 75

    23

    Returns: 766316916

  23. 1

    1

    Returns: 1

  24. 12

    12

    Returns: 57903

  25. 40

    6

    Returns: 724747205

  26. 11

    11

    Returns: 20491

  27. 97

    14

    Returns: 236897474

  28. 4

    4

    Returns: 19

  29. 95

    15

    Returns: 247412499

  30. 86

    25

    Returns: 841853953

  31. 86

    2

    Returns: 848983346

  32. 8

    8

    Returns: 951

  33. 25

    10

    Returns: 58550894

  34. 17

    12

    Returns: 10883852

  35. 53

    3

    Returns: 854458216

  36. 66

    1

    Returns: 2323520

  37. 22

    18

    Returns: 152118235

  38. 3

    3

    Returns: 7

  39. 78

    22

    Returns: 605442915

  40. 35

    2

    Returns: 841115074

  41. 34

    2

    Returns: 666881155

  42. 84

    2

    Returns: 583498129

  43. 55

    24

    Returns: 63557441

  44. 75

    2

    Returns: 292701596

  45. 58

    14

    Returns: 554381834

  46. 83

    24

    Returns: 463595731

  47. 20

    1

    Returns: 627

  48. 36

    24

    Returns: 568758458

  49. 34

    11

    Returns: 634519705

  50. 20

    20

    Returns: 258604642

  51. 83

    24

    Returns: 463595731

  52. 66

    19

    Returns: 213563016

  53. 55

    15

    Returns: 971709733

  54. 22

    3

    Returns: 860857296

  55. 60

    4

    Returns: 371770711

  56. 47

    24

    Returns: 896415504

  57. 30

    19

    Returns: 682628691

  58. 26

    21

    Returns: 899222021

  59. 97

    4

    Returns: 128772105

  60. 18

    18

    Returns: 31241170

  61. 95

    22

    Returns: 192964570

  62. 96

    21

    Returns: 257314950

  63. 72

    12

    Returns: 664849350

  64. 99

    17

    Returns: 713749590

  65. 39

    3

    Returns: 445226026

  66. 100

    20

    Returns: 818963941

  67. 54

    23

    Returns: 21970194

  68. 98

    22

    Returns: 894664887

  69. 67

    4

    Returns: 444328226

  70. 97

    2

    Returns: 395147803

  71. 91

    25

    Returns: 800797358

  72. 100

    19

    Returns: 423633321

  73. 51

    21

    Returns: 493477511

  74. 100

    2

    Returns: 378017182

  75. 37

    19

    Returns: 840710360

  76. 99

    2

    Returns: 136563450

  77. 2

    2

    Returns: 3

  78. 98

    1

    Returns: 150198136

  79. 14

    14

    Returns: 466199

  80. 100

    18

    Returns: 262026393

  81. 64

    24

    Returns: 270928094

  82. 97

    21

    Returns: 936421701

  83. 100

    23

    Returns: 469719472

  84. 99

    4

    Returns: 224806980

  85. 18

    18

    Returns: 31241170

  86. 96

    4

    Returns: 92260582

  87. 100

    1

    Returns: 190569292

  88. 87

    1

    Returns: 38887673

  89. 100

    3

    Returns: 506241817

  90. 99

    1

    Returns: 169229875

  91. 98

    2

    Returns: 303096421

  92. 96

    23

    Returns: 823306570

  93. 25

    25

    Returns: 78308836


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: