题解 | #整数与IP地址间的转换#
整数与IP地址间的转换
https://www.nowcoder.com/practice/66ca0e28f90c42a196afd78cc9c496ea
nums = input().split(".") long_bin = str(bin(int(input())))[2:].rjust(32, '0') com = '' for num in nums: com += str(bin(int(num)))[2:].rjust(8, '0') print(int('0b'+com, 2)) ip = [] for i in range(0,32,8): ip.append(str(int('0b'+long_bin[i:i+8], 2))) print('.'.join(ip))