题解 | #整数与IP地址间的转换#
整数与IP地址间的转换
http://www.nowcoder.com/practice/66ca0e28f90c42a196afd78cc9c496ea
# -*-coding:utf-8-*-
while True:
try:
input_ip , input_num = list(map(int , input().split("."))) , int(input())
i_b_s = ''
for i in input_ip:
i_b = format(i , '#010b').split("0b")[1]
i_b_s += (i_b)
print(int(i_b_s , 2))
input_num = format(input_num , '#034b').split("0b")[1]
for i in (0 , 8 , 16 , 24):
if i == 24:
num = int(input_num[i:i + 8] , 2)
print(num)
else:
num = int(input_num[i:i + 8] , 2)
print(num , end=".")
except:
break