Combinatorics: Trying to figure algorithm (about subsets) -
I'm trying to solve a problem at TopCoder. Basically I need algorithms for this:
Let's have a sequence [1, 2, ..., N]. Let's be less than m
1) Find all the later sizes of S. Me (which is easy - N ^ m).
2) After all the sized elements, find the elements where the elements are not allowed to be repeated (which is easy - (n!) / ((Nm)!).
4) Find all sorts of shapes, where the elements are in the order of nature and are not allowed to be repeated.
Still Part 2
Edit:
Basic Problem:
/ P>
to solve 4), note that w / o repetitions 'non-decreasing' means 'increasing' its Set all scenes of Advertising 2), in the form of sequence of calculation of event (including 0 for non-inclusion) for all elements in the model sequence This problem is (especially) with the restrictions equal to division and counterfeit count I do not think that by completing this condition However, there is a standard algorithm for calculating all the possibilities, such as. s created from
m without repeating the elements in the symmetry squares based on the set of elements that occur in a later version. Within each equivalence class, there is a rising sequence (elements sorted by
), the number of permutations of the size elements of each equivalence class. 4) - so the result is
(n!) / ((Nm)! * M!) = N \ select m .
s It can be written as a sequence of pairs
(s_i, k_i), i = 1..n; S_i \ in S, k_i \ in IN, \ foreach p, q in {1..n}, p! = Q: s_p! = S_q length exactly
n . According to increasing code by 'non-decaying', means an exclusive permissible arrangement of the given sequence by arranging elements according to S_I . Thus, the only degree of freedom is the count of the event M: abbreviated summaries should follow:
sum_ {i = 1..n} k_i = m .
IN ^ n n-tuples There is a closed formula for the number
Comments
Post a Comment