QOJ.ac

QOJ

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

#5611. 豌豆模式

الإحصائيات

你能看出下面这串数字的规律吗?

1, 11, 21, 1112, 3112, 211213, 312213, ...

每一项都描述了列表中前一项的构成。例如,项 3112 表示前一项由三个 1(即 3112 中的 31)和一个 2(即 3112 中的 12)组成。3112 之后的下一项表示它包含两个 1、一个 2 和一个 3。这就是一个“豌豆数列”(pea pattern)的例子。

豌豆数列可以以任何数字开头。例如,如果我们以数字 20902 开头,数列将变为 202219, 10113219, 1041121319,依此类推。注意,在前一个数字中未出现的数字在序列的下一个元素中会被跳过。

我们知道你在想什么。你一定在好奇 101011213141516171829 是否出现在以 20902 开头的数列中。好吧,今天真是你的幸运日,因为你马上就要找到答案了。

输入格式

输入包含一行,包含两个正整数 $n$ 和 $m$,其中 $n$ 是数列的起始值,$m$ 是目标值。两个值均在 $0$ 到 $10^{100} - 1$ 之间。

输出格式

如果 $m$ 出现在以 $n$ 开头的豌豆数列中,请显示它在列表中的位置(初始值位于第 1 位)。

如果 $m$ 没有出现在数列中,请显示 Does not appear。我们认为所有这些数列都会在 100 个数字内收敛到一个重复的序列,但如果你发现一个超过 100 个数字的序列,请显示 I’m bored

样例

样例输入 1

1 3112

样例输出 1

5

样例输入 2

1 3113

样例输出 2

Does not appear

样例输入 3

20902 101011213141516171829

样例输出 3

10

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.