#include <iostream>
#include <string>
using namespace std;
int main(void){
string str,tstr;
int Time;
cin>>str>>Time;
if(Time==1){
cout<<str;
return 0;
}
for(int i=2;i<=Time;i++){
char c=str[0];
tstr+=str[0];
int cnt=1;
for(int j=1;j<str.size();j++){
if(c==str[j]){
cnt++;
}else{
tstr+=(char)cnt+'0';
tstr+=str[j];
c=str[j];
cnt=1;
}
}
tstr+=(char)cnt+'0';
str.clear();
for(int j=0;j<tstr.size();j++) str+=tstr[j];
tstr.clear();
}
cout<<str;
return 0;
}
1140 Look-and-say Sequence
最新推荐文章于 2024-07-17 18:07:42 发布