QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 32 MB Points totaux : 100

#12978. Przesmyks 的数字

Statistiques

在遥远的过去,生活着一个名为 Przesmyk(读作:“Pshaesmix”)的部落。在那个时代,他们是杰出的数字专家。他们仅使用“+”和“-”这两个符号来书写数字,其仪式意义至今仍是历史学家研究的课题。已知 Przesmyk 人能够书写所有的自然数 0, 1, 2, …。他们使用“+”和“-”字符序列来表示数字,但出于宗教原因,某些序列是被禁止的。每年,祭司都会宣布在数字表示中连续出现的“-”字符的最大允许数量。根据年份的不同,这个限制在 1 到 113 之间。数字的表示规则如下:所有合法的“+”和“-”字符序列按长度由短到长排序,长度相同的序列按字母顺序排序(与字典顺序相同,假设“-”排在“+”之前)。按此顺序排列的序列分别代表连续的数字 0, 1, 2, …。例如,如果规定连续的“-”字符不能超过一个,那么数字的表示如下:

    0 -    4 ++    8 ++-

    1 +    5 -+-    9 +++    

    2 -+    6 -++    10 -+-+

    3 +-    7 +-+    11 -++-

数字的表示方式会随着限制的变化而改变。例如,当允许连续出现两个或更多“-”字符时,数字 2 就会被写成“--”。这种情况给当代历史学家带来了很大的困扰。

请编写一个程序,完成以下任务:

  • 读取两个关于数字表示中连续“-”字符最大允许数量的限制,以及一组根据第一个限制书写的 Przesmyk 数字;
  • 将这些数字转换为根据第二个限制书写的 Przesmyk 数字;
  • 输出转换后的新表示。

标准输入的第一行包含三个正整数 $m_1$、$m_2$ 和 $n$,以空格分隔,$1 \le m_1, m_2 \le 113$,$1 \le n \le 10$。$m_1$ 是输入数据中数字表示所允许的连续“-”字符的最大数量,$m_2$ 是需要输出的数字表示所允许的连续“-”字符的最大数量,$n$ 是需要转换的数字个数。接下来的 $n$ 行每行包含一个数字(由“-”和“+”组成的字符串)。这些数字字符串的长度均不超过 $1\,000$。

程序应将转换后的数字按顺序输出到标准输出,每行一个,采用符合限制 $m_2$ 的 Przesmyk 表示法。

样例

输入格式 1

1 2 3
-+-
-+
+-+

输出格式 1

++
--
-+-

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.