def CheckPasswd(passwd): #检查长度 if len(passwd)<=8: return "NG" #检查字符类型 hasNum = 0 hasLowercase = 0 hasUppercase = 0 hasOther = 0 for i in range(len(passwd)): ascaii = ord(passwd[i]) if ascaii >=ord('0') and ascaii <= ord('9'): hasNum = 1 elif ascaii >=ord('a') and ascaii <= ord('z'): hasLowercase = 1 elif ascaii >=ord('A') and ascaii <= ord('Z'): hasUppercase = 1 else: hasOther = 1 types = hasNum + hasLowercase + hasUppercase + hasOther if types <3: return "NG" #检查长度大于2的重复子串 for i in range(len(passwd)-3): #检查每个长度为3的子串是否重复出现即可 substr = passwd[i:i+3] if len(passwd.split(substr))>2: return "NG" return "OK" #三项条件都满足 while 1: try: passwd = input().strip() print(CheckPasswd(passwd)) except EOFError: break