t = list(map(int, input().split('.')))
s1 = list(map(int, input().split('.')))
s2 = list(map(int, input().split('.')))
def f2(s):
p = '1'
cnt = 0
for x in s:
if x != p:
cnt += 1
p = x
return cnt <= 1
def f1(nums):
for x in nums:
if x < 0 or x > 255:
return False
return True
def cal(nums1, nums2):
ans = []
for x, y in zip(nums1, nums2):
ans.append(x & y)
return ans
tt = ''
for x in t:
d = bin(x)[2:]
m = len(d)
tt += '0' * (8 - m) + d
if not f1(t) or not f1(s1) or not f1(s2) or not f2(tt):
print(1)
exit()
a1 = cal(t,s1)
a2 = cal(t,s2)
# print(a1,a2,tt)
if not f1(a1) or not f1(a2):
exit(print(1))
if a1 == a2:
print(0)
else:
print(2)
对输入字符串进行.分割,
然后分别检验三个码是否规范,不规范范围1
否则判断与运算后是否符合规范
返回对应的值

京公网安备 11010502036488号