1 solutions

  • 0
    @ 2025-3-14 18:43:10
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int n;
    	string x;
    	cin>>x>>n;
    	n--;
    	while(n--)//第i次迭代 
    	{
    		string t;
    		for(int i=0;i<x.size();i++) //枚举整个字符串 
    		{
    			int j=i;
    			while(j<x.size()&&x[i]==x[j]) j++; //取出相同的一段 
    			j--;
    			t=t+to_string(j-i+1)+x[i];
    			i=j;
    		}
    		x=t;
    	}
    	cout<<x;
    	return 0;
    }
    
    • 1

    Information

    ID
    692
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    5
    Tags
    # Submissions
    33
    Accepted
    13
    Uploaded By