题解 | 合法IP
def is_ip(s): if s.count('.') != 3: return 0 else: ls = s.split('.') for i in ls: if i.isdigit(): if 0<int(i)<=255 and i[0] != '0': continue elif i == '0': continue else: return 0 else: return 0 return 1 while True: try: s = input() if is_ip(s): print('YES') else: print('NO') except: break