문제2018--Inversion2

### 2018: Inversion2

실행시간 제한: 5 Sec  메모리사용 제한: 128 MB  Special Judge
제출: 16  통과: 6
[제출] [채점기록] [묻고답하기]

#### 문제 설명

The inversion number of an integer sequence a1, a2, . . . , an is the number of pairs (ai, aj) that satisfy i < j and ai > aj . Given n and the inversion number m, your task is to find the smallest permutation of the set { 1, 2, . . . , n }, whose inversion number is exactly m.
A permutation a1, a2, . . . , an is smaller than b1, b2, . . . , bn if and only if there exists an integer k such that aj = bj for 1 <= j < k but ak < bk.

#### 입력 설명

The input consists of several test cases. Each line of the input contains two integers n and m. Both of the integers at the last line of the input is −1, which should not be processed. You may assume that 1 <= n <= 1000000 and 0 <= m <= n(n − 1)/2.

#### 출력 설명

For each test case, print a line containing the smallest permutation as described above, separates the numbers by single spaces.

#### 입력 예시 Copy

5 9
7 3
-1 -1

#### 출력 예시 Copy

4 5 3 2 1
1 2 3 4 7 6 5