0135. Combinations

Input file name: combo.in
Output file name: combo.out
Time limit: 500 ms
Memory limit: 64 megabytes

A combination of k elements out of n is an increasing sequence of k integer numbers in range from 1 to n.

Combinations can be sorted in lexicographical order. Your task will be to find a specified combination by its position in that order.

Input file

Input file contains three integer numbers n, k, l (1 ≤ n ≤ 100, 1 ≤ k ≤ n, 1 ≤ l ≤ Cnk).

Output file

Output file must contain k integer numbers, separated by spaces – l-th combination of k elements out of n in lexicographical order.

Examples:

combo.incombo.out
3 3 11 2 3


Source: Petrozavodsk Summer 2003. Blitz Kontest, Monday, August 25
Author: Andrew Lopatin, Nick Durov

Discuss       Submit a solution



Printable version