#include #include #pragma GCC optimize("Ofast,inline") #define MAXLEN 18 // returns 1 if valid, otherwise 0 int validate(char *id); int main(void) { char *id = malloc(sizeof(char) * MAXLEN); int lines; scanf("%d", &lines); for (int i = 0; i < lines; i++) { scanf("%s", id); if (validate(id)) { printf("right\n"); } else { printf("wrong\n"); } } free(id); return 0; } int validate(char *id) { char lasttable[] = "10X98765432"; int factor[] = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2}; int last = 0; for (int i = 0; i < 17; i++) { last += (id[i] - '0') * factor[i]; } last = last % 11; if (lasttable[last] == id[17]) { return 1; } else { return 0; } }