QOJ.ac

QOJ

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

#23752. 問題 2

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

入力例

5
11

出力

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.