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 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 .

Advertising 2), in the form of sequence of calculation of event (including 0 for non-inclusion) for all elements in the model sequence 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 .

This problem is (especially) with the restrictions equal to division and counterfeit count I do not think that by completing this condition IN ^ n n-tuples There is a closed formula for the number

However, there is a standard algorithm for calculating all the possibilities, such as.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -