题解 | #判断两个IP是否属于同一子网#
判断两个IP是否属于同一子网
http://www.nowcoder.com/practice/34a597ee15eb4fa2b956f4c595f03218
人生苦短,我用python 都不用做二进制,直接&运算hhh
while True:
try:
x = input().split('.')
y = input().split('.')
z = input().split('.')
m, n = [], []
for i in range(len(x)):
x[i] = int(x[i])
y[i] = int(y[i])
z[i] = int(z[i])
if x[0]!= 255 or x[3]!=0 or max(x+y+z)>255 or min(x+y+z)<0:
print('1')
else:
for i in range(len(x)):
m.append(int(x[i]) & int(y[i]))
n.append(int(x[i]) & int(z[i]))
if m == n:
print('0')
else:
print('2')
except:
break