C++ 代码
#include<bits/stdc++.h>
#include<cstring>
using namespace std;
#define int long long
string f(string s)
{
string res="";
int n = s.size();
int j=0,i=0;
while(j<n)
{
while(j<n&&s[i]==s[j])
{
j++;//快指针
}
res += to_string(j-i) + s[i];
i = j;
}
return res;
}
signed main()
{
string s;
int n;
cin>>s>>n;
for(int i=0;i<n;i++)
{
s = f(s);
if(i==n-1) cout<<s;
}
return 0;
}