Permutations

Traditional Problems Lexicographic Ordering Problems

Straight to the problem, if n = 3 and m = 5 then the lexicographic order of the combination is :

1 2 3 = 1
1 2 4 = 2
1 2 5 = 3
1 3 4 = 4 
1 3 5 = 5
1 4 5 = 6
2 3 4 = 7
2 3 5 = 8
2 4 5 = 9
3 4 5 = 10
You should've got the idea of what the problem is all about .

Input and Output

There are two subtask for this problem.

Solution (Yogy Namara) :

Examine the following figure :
10--6--3--1
    |  |  1
    |  |  1
    |  2--1
    |  |  1
    |  1--1
    3--2--1
    |  |  1
    |  1--1
    1--1--1
Pascal triangle
1
1  1
1  2  1
1  3  3  1
1  4  6  4  1
1  5 10 10  5  1
Got the idea?

yogy-n@sby.mega.net.id GeoCities