思路

  1. 暴力解法

Answer

#include<stdio.h>
#include<string.h>

int main() {
    char str[1000];
    while (gets(str)) {
        int i, j;
        int len, flag;
        int a1 = 0, a2 = 0, a3 = 0, a4 = 0;
        len = strlen(str);

        //判断长度
        if (len < 9)
            printf("NG\n");
        else {
            //如果长度满足,进行类型判断
            for (i = 0; i < len; i++) {
                if (str[i] >= 'a' && str[i] <= 'z')
                    a1 = 1;
                else if (str[i] >= 'A' && str[i] <= 'Z')
                    a2 = 1;
                else if (str[i] >= '0' && str[i] <= '9')
                    a3 = 1;
                else
                    a4 = 1;
            }
            if (a1 + a2 + a3 + a4 < 3)
                printf("NG\n");
            //如果类型也满足,开始判断公共子串
            else {
                flag = 0;
                for (i = 0; i < len - 6; i++) {
                    for (j = i + 3; j < len - 3; j++)
                        if (str[j] == str[i] && str[j + 1] == str[i + 1] && str[j + 2] == str[i + 2])
                            flag = 1;
                }
                if (flag == 1)
                    printf("NG\n");
                else
                    printf("OK\n");
            }
        }
    }
}