参考文献
C++ 代码
#include<bits/stdc++.h>
using namespace std;
string dfs(int n, int first)
{
if(n == 1) return to_string(first);
else
{
string ans;
string res = dfs(n-1, first);
for(int i = 0; i < res.size();)
{
int j = i;
int count =0;
while(res[j] == res[i])
{
++j;
++count;
}
ans += res[i] + to_string(count);
i = j;
}
return ans;
}
}
int main()
{
int n, x;
cin >> x >> n;
cout << dfs(n,x) << endl;
return 0;
}