PivotOJ

Gwen's Gift

시간 제한: 1000ms메모리 제한: 512MB출처: ICPC Rocky Mountain Regional 2018BOJ 22280

문제

Gwen loves most numbers. In fact, she loves every number that is not a multiple of nn (she really hates the number nn). For her friends' birthdays this year, Gwen has decided to draw each of them a sequence of n1n-1 flowers. Each of the flowers will contain between 11 and n1n-1 flower petals (inclusive). Because of her hatred of multiples of nn, the total number of petals in any non-empty contiguous subsequence of flowers cannot be a multiple of nn. For example, if n=5n = 5, then the top two paintings are valid, while the bottom painting is not valid since the second, third and fourth flowers have a total of 1010 petals. (The top two images are Sample Input 33 and 44.)

Gwen wants her paintings to be unique, so no two paintings will have the same sequence of flowers.  To keep track of this, Gwen recorded each painting as a sequence of n1n-1 numbers specifying the number of petals in each flower from left to right.  She has written down all valid sequences of length n1n-1 in lexicographical order. A sequence a1,a2,,an1a_1,a_2,\dots, a_{n-1} is lexicographically smaller than b1,b2,,bn1b_1, b_2, \dots, b_{n-1} if there exists an index kk such that ai=bia_i = b_i for i<ki < k and ak<bka_k < b_k.

What is the kkth sequence on Gwen's list?

입력

The input consists of a single line containing two integers nn (2n10002 \leq n \leq 1\,000), which is Gwen's hated number, and kk (1k10181 \leq k \leq 10^{18}), which is the index of the valid sequence in question if all valid sequences were ordered lexicographically. It is guaranteed that there exist at least kk valid sequences for this value of nn.

출력

Display the kkth sequence on Gwen's list.

예제

예제 1

입력
4 3
출력
2 1 2

예제 2

입력
2 1
출력
1

예제 3

입력
5 22
출력
4 3 4 2

예제 4

입력
5 16
출력
3 3 3 3
코드를 제출하려면 로그인하세요.