QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 256 MB 總分: 10

#6026. 单词

统计

本题要求找出由集合 $\{a, b, c\}$ 中的字母组成的、长度不超过 $n$ 的所有非空单词中,按字典序排列的第 $k$ 个单词。要求这些单词中任意两个相邻的字母都不相同。

回想一下,单词 $s$ 小于单词 $t$ ($s \neq t$) 的字典序定义为:$s$ 是 $t$ 的前缀,或者在 $s$ 和 $t$ 第一个不同的位置上,$s$ 中的字母在字母表中的顺序比 $t$ 中的字母靠前。

输入格式

输入仅一行,包含两个整数 $n$ 和 $k$ ($1 \le n \le 10^6$, $1 \le k \le 10^{18}$)。

输出格式

如果满足条件的单词总数少于 $k$ 个,则输出 NIE。否则,在唯一的一行输出中打印出所求的单词。

样例

样例输入 1

3 7

样例输出 1

acb

样例输入 2

2 10

样例输出 2

NIE

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.