You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
481 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
int main() {
1 year ago
string s;
cin >> s;
int m;
cin >> m;
m--;
while (m--) {
string t;
for (int i = 0; i < s.size(); i++) {
int c = 1;
while (i + 1 < s.size() && s[i + 1] == s[i]) {
c++;
i++;
}
t = t + to_string(c) + s[i];
2 years ago
}
1 year ago
s = t;
2 years ago
}
1 year ago
cout << s << endl;
2 years ago
return 0;
1 year ago
}