题目:1140 Look-and-say Sequence (20 分)
分析:模拟。第一次看题,意思理解了一会┭┮﹏┭┮
例如第一个是:11231,那么下一个就是:12213111
因为第一个中有2个1,1个2,1个3,1个在这里插入代码片
1,所以对应的是:12,21,31,11
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<queue>
#include<stack>
#include<map>
using namespace std;
int n,m,k;
int main(){
string s;
cin>>s>>m;
for(int i = 0 ; i < m-1 ; i++)
{
int len = s.size();
string t = "";
for(int j = 0 ; j < len ;j++)
{
char c = s[j];
int cnt = 0;
while(s[j] == c)
{
cnt++;
j++;
}
j--;
t += c;
t += to_string(cnt);
}
s = t;
}
cout<<s;
return 0;
}