[BOJ 15441] Vera and Mean Sorting
View as PDFThe harmonic mean of a sequence of positive integers x1, · · · , xN is</p>
[H\left(x_1, \cdots, x_N\right) = \left( \frac{\sum_{i=1}^{N}{x_i^{-1}}}{N}\right)^{-1} \text{.}]
Vera classifies an array of positive integers A = [A1, · · · , AN] of length N as K-mean-sorted if M(i) ≥ M(i + 1) for 1 ≤ i ≤ N − K where
[M\left(i\right) = H\left(A_i, \cdots, A_{i+K-1}\right) \text{.}]
A permutation P is an ordered set of integers P1, P2, · · · , PN , consisting of N distinct positive integers, each of which are at most N.
Permutation P is lexicographically smaller than permutation Q if there is an i (1 ≤ i ≤ N), such that Pi < Qi, and for any j (1 ≤ j < i) Pj = Qj.
Given integers N and K, help Vera find the lexicographically smallest permutation P of integers 1 to N such that P is K-mean-sorted but not L-mean-sorted for 1 ≤ L ≤ N − 1, L ≠ K.
If no such permutation exists output 0.
입력 형식
The input will be in the format:</p>
N K
Constraints:
- 2 ≤ N ≤ 100
- 1 ≤ K ≤ N − 1
- N, K are integers
Output one line with the desired permutation. If such permutation does not exist output one line with 0.
예제 입력 1
3 2
예제 출력 1
2 3 1
예제 입력 2
4 1
예제 출력 2
0
Comments