#include <stdio.h> #include <stdlib.h> #include <string.h> #define max 3000 #define row 1001 #define col 1001 #define N 8 /* 密码要求: 1.长度超过8位 2.包括大小写字母.数字.其它符号,以上四种至少三种 3.不能有相同长度大于2的子串重复 */ int main() { char s[max]; char d[max]; char ss[N][col]; int seq[N]; int cnt[N]; int i = 0, j = 0, k = 0, m = 0, n = 0; char a, b, c; while (gets(s) != NULL) { n = strlen(s); if (n <= 8) { puts("NG"); } else { m = 0; for (i = 0; i < n; i++) { if ((s[i] >= 'a') && (s[i] <= 'z')) { m |= 0x01; } else if ((s[i] >= 'A') && (s[i] <= 'Z')) { m |= 0x02; } else if ((s[i] >= '0') && (s[i] <= '9')) { m |= 0x04; } else { m |= 0x08; } for (j = i + 3; j < n; j++) { if (s[i] == s[j]) { if (s[i + 1] == s[j + 1]) { if (s[i + 2] == s[j + 2]) { i = n - 1; m = 0; break; } } } } } j = 0; while (m != 0) { if ((m & 1) != 0) { j++; } m >>= 1; } if (j < 3) { puts("NG"); } else { puts("OK"); } } } return 0; }