#include <cctype> #include <iostream> #include <string> using namespace std; bool check(string& str) { int mask = 0; for (char c : str) { if (c >= 'a' && c <= 'z') { mask |= 1; } else if (c >= 'A' && c <= 'Z') { mask |= 2; } else if(c >= '0' && c <= '9'){ mask |= 4; } else { mask |= 8; } } int count = 0; while(mask){ mask = mask & (mask - 1); count++; } return count >= 3; } bool checkReaptString(string& str){ int n = str.size(); for(int i = 0; i < n - 3; i++){ string pat = str.substr(i, 3); int j = i + 3; if(str.find(pat,j) != string::npos){ return false; } } return true; } int main() { string str; while (cin >> str) { // 注意 while 处理多个 case if(str.size() <= 8 || !check(str) || !checkReaptString(str)){ cout << "NG" << endl; continue; } cout << "OK" << endl; } return 0; } // 64 位输出请用 printf("%lld")