Merge branch 'main' of http://10.10.14.176:3000/huanghai/python
commit
7c33ba73cb
@ -0,0 +1,19 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
using namespace std;
|
||||||
|
string s;
|
||||||
|
int n;
|
||||||
|
int main() {
|
||||||
|
cin >> s >> n;
|
||||||
|
n--;
|
||||||
|
while (n--) {
|
||||||
|
string t;
|
||||||
|
for (int i = 0; i < s.size(); i++) {
|
||||||
|
int cnt = 1;
|
||||||
|
while (i + 1 < s.size() && s[i] == s[i + 1]) cnt++, i++;
|
||||||
|
t += to_string(cnt) + s[i];
|
||||||
|
}
|
||||||
|
s = t;
|
||||||
|
}
|
||||||
|
cout << s << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
using namespace std;
|
||||||
|
string s;
|
||||||
|
int n;
|
||||||
|
int main() {
|
||||||
|
cin >> s >> n;
|
||||||
|
n--;
|
||||||
|
while(n--){
|
||||||
|
string t;
|
||||||
|
for (int i = 0; i < s.size(); i++){
|
||||||
|
int cnt = 1;
|
||||||
|
while (i + 1 < s.size() && s[i + 1]==s[i]) cnt++, i++;
|
||||||
|
t += to_string(cnt) + s[i];
|
||||||
|
}
|
||||||
|
s = t;
|
||||||
|
}
|
||||||
|
cout << s << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in new issue