You are given the ints N and K.
Let S be the set of all arrays that have the following properties:
Morphing an array A is an operation that consists of three steps:
- 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.
For example, suppose that A = [1,3,3,4].
One possible morphing of this array will look as follows:
- Choose two distinct integers x and y, each between 1 and N, inclusive.
- 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.
- Finally, swap two elements of A: the elements with the 1-based indices x and y.
- We choose x=1 and y=3.
- After changing the values in A, we have the array [3,1,1,4].
- 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.
|Method signature:||int findsz(int N, int K)|
|(be sure your method is public)|
|-||N will be between 1 and 100, inclusive.|
|-||K will be between 1 and min(25, N), inclusive.|
|The only valid array is .
The subset T must contain this array.|
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.
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.
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.
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)2010, TopCoder, Inc. All rights reserved.