题目描述
分析:字符串模拟
string c++详解 find_first_not_of() find_first_of()
C++中的String的常用函数用法总结
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
int main() {
string s;
ll n;
cin >> s >> n;
while (--n) {
string t;
for (ll i = 0, j; i < s.size(); i = j) {
j = s.find_first_not_of(s[i], i + 1);
if (j == -1)
j = s.size();
t += string(1, s[i]) + to_string(j - i);
}
s = t;
}
cout << s;
return 0;
}