题解 | #整数与IP地址间的转换#
整数与IP地址间的转换
https://www.nowcoder.com/practice/66ca0e28f90c42a196afd78cc9c496ea
while 1:
try:
line1 = input()
line2 = int(input())
# IP地址转换成10进制数
data1 = [int(i) for i in line1.split(".")]
res1 = data1[0] * 2**24 + data1[1] * 2**16 + data1[2] * 2**8 + data1[3]
print(res1)
# 10进制数转换为IP地址
res2 = [0, 0, 0, 0]
# 32位-24位上的数
res2[0] = line2 // (2**24)
# 24位-16位上的数
res2[1] = (line2 % (2**24)) // (2**16)
# 16位-8位上的数
res2[2] = (line2 % (2**16)) // (2**8)
# 最后8位数
res2[3] = line2 % (2**8)
res = [str(i) for i in res2]
print(".".join(res))
except:
break

