QOJ.ac

QOJ

Time Limit: 3 s Memory Limit: 64 MB Total points: 20

#23752. 字串操作

Statistics

題目描述

當畀定一個淨係由 $0$ 到 $9$ 嘅數字組成嘅字串嗰陣,考慮按照以下規則由呢個字串整出新字串嘅操作。由左端開始按順序每次 $1$ 個字符咁讀取畀定嘅字串,如果相同嘅數字 $a$ 連續出現咗 $r$ 個,就按呢個順序寫出個數 $r$ 同埋數字 $a$,中間唔用空格隔開。一直讀到畀定字串嘅右端,直到最後一次寫出完畢為止,就算中途寫出咗好多次,成個過程都總共計做 $1$ 次操作。第 $2$ 次及之後嘅操作,將前一次操作寫出嘅字串當做畀定嘅字串,進行相同嘅操作。例如,當畀定字串 122244 嗰陣,由左端開始按順序係 $1$ 個 $1$、$3$ 個 $2$、$2$ 個 $4$,所以做 $1$ 次呢個操作得到嘅字串係 113224;而喺 44444444444($11$ 個 $4$)嘅情況下,得到嘅字串係 114。

請編寫一個程式,輸出對唔超過 $100$ 個字符嘅畀定字串進行 $n$ 次上述操作之後得到嘅字串。不過,設 $n \le 20$。

輸入檔案嘅檔名係 input.txt。input.txt 由 $2$ 行組成,第 $1$ 行寫住操作次數 $n$,第 $2$ 行寫住最初嘅字串。

輸出檔案嘅檔名係 output.txt。output.txt 有 $1$ 行,請喺進行咗指定次數嘅操作之後得到嘅字串後面加個換行。

範例 1

範例輸入 1

5
11

範例輸出 1

13112221

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.