Run Length Encoding(스케줄 길이 압축)

2453 단어 사유

                                                 Run Length Encoding


Description


Your task is to write a program that performs a simple form of run-length encoding, as described by the rules below.  Any sequence of between 2 to 9 identical characters is encoded by two characters. The first character is the length of the sequence, represented by one of the characters 2 through 9. The second character is the value of the repeated character. A sequence of more than 9 identical characters is dealt with by first encoding 9 characters, then the remaining ones.  Any sequence of characters that does not contain consecutive repetitions of any characters is represented by a 1 character followed by the sequence of characters, terminated with another 1. If a 1 appears as part of the sequence, it is escaped with a 1, thus two 1 characters are output.

Input


The input consists of letters (both upper- and lower-case), digits, spaces, and punctuation. Every line is terminated with a newline character and no other characters appear in the input.

Output


Each line in the input is encoded separately as described above. The newline at the end of each line is not encoded, but is passed directly to the output.

Sample Input


AAAAAABCCCC12344

Sample Output

6A1B14C
11123124

제목: 한 줄에 입력한 문자열
1: 중복된 문자열로 구성된 하위 문자열은 숫자+문자로 길이를 줄이고, 길이가 9를 초과하면 9+문자로 한 단락을 표시한다(나머지 길이는 동일하다)
예: AAAAA 출력 6A
2: 중복되지 않은 문자열로 구성된 하위 문자열은 첫 번째 문자열에'1'을 하나 더 출력하고, 하위 문자열의'1'에 대해서는'11'로 출력합니다.
예: B 출력 1B1 123 출력 11231

AC Code:

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define mod 998244353
#define Max 0x3f3f3f3f
#define Min 0xc0c0c0c0
#define mst(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i

좋은 웹페이지 즐겨찾기