HDU 1020 Encoding
#include"stdio.h" #include"string.h" char str[10000]; void print(){ scanf("%s",str); int i = 0,len = strlen(str),k; char c ; while(i < len){ c = str[i]; k = i; while(str[++i] == c){ } if(i - k > 1) printf("%d%c",i - k,c); else printf("%c",c); } printf("\n"); } int main(){ int nCases; scanf("%d",&nCases); while(nCases--){ print(); } return 0; }