QOJ.ac

QOJ

حد الوقت: 1.0 s حد الذاكرة: 2048 MB مجموع النقاط: 100

#15918. 格温的礼物

الإحصائيات

Gwen 喜欢绝大多数数字。事实上,她喜欢所有不是 $n$ 的倍数的数字(她真的很讨厌数字 $n$)。为了庆祝今年朋友们的生日,Gwen 决定为他们每个人画一幅由 $n - 1$ 朵花组成的序列。每朵花将包含 $1$ 到 $n - 1$(含)片花瓣。由于她讨厌 $n$ 的倍数,因此任何非空连续花朵子序列的花瓣总数都不能是 $n$ 的倍数。例如,如果 $n = 5$,那么顶部的两幅画是合法的,而底部的画是不合法的,因为第二、第三和第四朵花的花瓣总数为 $10$。(顶部的两幅图分别对应样例输入 3 和 4。)

Gwen 希望她的画作是独一无二的,因此没有两幅画会具有相同的花朵序列。为了记录这一点,Gwen 将每幅画记录为一个由 $n - 1$ 个数字组成的序列,从左到右指定每朵花的花瓣数。她按字典序写下了所有长度为 $n - 1$ 的合法序列。如果存在一个索引 $k$ 使得对于所有 $i < k$ 有 $a_i = b_i$ 且 $a_k < b_k$,则序列 $a_1, a_2, \dots, a_{n-1}$ 在字典序上小于 $b_1, b_2, \dots, b_{n-1}$。

Gwen 的列表上的第 $k$ 个序列是什么?

输入格式

输入仅包含一行,其中包含两个整数 $n$($2 \le n \le 1\,000$),即 Gwen 讨厌的数字,以及 $k$($1 \le k \le 10^{18}$),表示如果将所有合法序列按字典序排序,所询问的合法序列的索引。保证对于给定的 $n$,至少存在 $k$ 个合法序列。

输出格式

输出 Gwen 列表上的第 $k$ 个序列。

样例

输入样例 1

4 3

输出样例 1

2 1 2

输入样例 2

2 1

输出样例 2

1

输入样例 3

5 22

输出样例 3

4 3 4 2

输入样例 4

5 16

输出样例 4

3 3 3 3

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.