3 条题解

  • 0
    @ 2024-4-14 17:39:13
    #include<cstdio>
    #include<iostream>
    using namespace std;
    
    int main(){
    	
    	string s;
    	cin>>s;
    	int len=s.length();
    	char now=s[0];
    	int count=1;
    	
    	for(int i=1;i<len;++i){
    		if(s[i]==s[i-1]){
    			count++;
    		}
    		else{
    			cout<<now<<count;
    			count=1;
    			now=s[i];
    		}
    	}
    	
    	cout<<now<<count;
    
    	return 0;
    }
    
    • 0
      @ 2024-4-13 17:07:09
      s = input()
      n = len(s)
      t = 1
      ans = 0
      for i in range(n-1):
          if s[i]==s[i+1]:
              t+=1
          else:
              print(s[i],end = "")
              print(t,end = "")
              t=1
      print(s[i+1],end = "")
      print(t,end = "")
      
      • 0
        @ 2024-4-12 11:59:00
        #include<bits/stdc++.h>
        using namespace std;
        string s;
        int main(){
            ios::sync_with_stdio(0);
            cin.tie(0);
            cout.tie(0);
            cin>>s;
            for(int i=0;i<s.size();){
                int ans=1;
                int j=i+1;
                while(s[j]==s[i]){
                    ans++;
                    j++;
                }
                    cout<<s[i]<<ans;
                    i=j;
            }
        }
        
        • 1

        信息

        ID
        65
        时间
        1000ms
        内存
        256MiB
        难度
        3
        标签
        递交数
        130
        已通过
        74
        上传者