###### tags: `I2P(I)` # 14018 Another Hacker Domo ## Brief Decode the zipped string. ## Solution There're several skill to solve this problem, please refer to the sample code and the comment. ## Reference Code ```cpp= #include <stdio.h> #include <string.h> // you can write these two functions by yourself, or include the ctype.h library. int isdigit(char ch) { return ch >= '0' && ch <= '9'; } int isalpha(char ch) { return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'); } int main() { char str[1001], ans[1000000]; // keeping read the string until reach the end of the file. while (scanf("%s", str) != EOF) { int len = strlen(str); int now = 0; int good = 1; // whether the format is correct. for (int i = 0; i < len;) { // we will start every [integer][alpha] unit from here. if (!isdigit(str[i])) { // if it's not start from integer good = 0; break; } else { // ------------ calculating the integer. int sum = 0; while (i < len && isdigit(str[i])) { sum *= 10; sum += (str[i] - '0'); i++; } // ------------ if (sum == 0) { // if integer is 0 good = 0; break; } if (i >= len) { // if there is no any further character in the string. good = 0; break; } else if (str[i] == '\'') { // if next character is ' if (i+2 >= len) { // if i+2 is out of the range (since we need to check whether str[i+2] is ') good = 0; break; } else if (!(isdigit(str[i+1]) && str[i+2] == '\'')) { good = 0; break; } else { for (int z = 0; z < sum; z++) { ans[now++] = str[i+1]; } i += 3; } } else if (isalpha(str[i])) { // the next character is alphabet. for (int z = 0; z < sum; z++) ans[now++] = str[i]; i++; } else { good = 0; break; } } } if (!good) { printf("Domo cannot crack this computer\n"); } else { ans[now++] = 0; printf("%s\n", ans); } } } ```