Dice
Time limit1sMemory limit128 MB
Find the k-th non-decreasing sequence of length m with values from 1 to n, in lexicographic order.
- Level
Medium5 of 10
- Topics
- Combinatorics, Dynamic programming, Math, Greedy
- Solved
- No attempts yet
Problem
Bytie has dice. Each die has faces, and the faces show pips respectively.
Bytie only cares about arrangements of the dice in a row where the top faces, read from left to right, form a non-decreasing sequence: every value is at least the value before it.
To compare two such arrangements, look at the leftmost position where they differ; the arrangement with the smaller value there is considered the "worse" one. In other words, the arrangements are ordered lexicographically.
Starting from the worst arrangement, in which every top face shows , Bytie lists all such arrangements in this order. Determine the -th arrangement in the list.
Write a program that
- reads three integers , , and ,
- prints the -th arrangement in the order described above.
Input
The only line contains three positive integers , , and (, , ).
The input is guaranteed to be such that the -th arrangement exists.
Output
Print the top faces of the dice in the requested -th arrangement, as positive integers separated by single spaces on one line.