2017 Winter Waterloo Local ACM Contest, Problem C
The harmonic mean of a sequence of positive integers is
Vera classifies an array of positive integers of length as -mean-sorted if for where
A permutation is an ordered set of integers , consisting of distinct positive integers, each of which are at most .
Permutation is lexicographically smaller than permutation if there is (), such that , and for any () .
Given integers and , help Vera find the lexicographically smallest permutation of integers to such that is -mean-sorted but not -mean-sorted for , .
If no such permutation exists, output 0
.
Constraints
- are integers
Input Specification
The input will be in the format:
Output Specification
Output one line with the desired permutation. If such permutation does not exist, output one line with 0
.
Sample Input 1
3 2
Sample Output 1
2 3 1
Sample Input 2
4 1
Sample Output 2
0
Comments