#include <iostream> #include <iomanip> #include <cstdlib> #include <string> #include <sstream> using namespace std; string num2str(int i) { stringstream ss; ss<<i; return ss.str(); } bool isLower(char s) { return (int)s >= (int)'a' && (int)s <= (int)'z'; } int main(){ string s; cin>>s; //bcaaaaaaaeeeeeeeeeeeaaaaaakkk kkkA7bcE11f for(int i = 0 ; i< s.length(); i++) { int j = i+ 1; for(; j < s.length();j++) { if(s[i] != s[j] && isLower(s[i])) break; } if(j - i > 1 && isLower(s[i])) { string s1 = s.substr(j) + char((int)s[i] - 32) + num2str(j-i) + s.substr(0,i); cout<<s1<<endl; s = s1; i = -1; } } cout<<s<<endl; // cout<<setiosflags(ios::fixed)<<setprecision(4)<<s<<endl; // cout<< setiosflags(ios::fixed)<<setprecision(4) <<c<<endl; }
http://hmbb.hustoj.com/problem.php?id=1005