import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNextLine()) { String str = in.nextLine(); if (str.indexOf(".") > 0) { System.out.println(toNo(str.split("\\."))); } else { System.out.println(toIP(Long.parseLong(str))); } } } static String toIP(long no) { StringBuilder sb = new StringBuilder(); // IP地址有四段 每段二进制长度是八位 与Integer.SIZE和Byte.SIZE匹配 // 从高位开始 每八位 掩一次 再右移得到 IP段值 for (int i = Integer.SIZE - Byte.SIZE; i >= 0; i -= Byte.SIZE) { sb.append((no & (0xff << i)) >> i).append("."); } return sb.substring(0, sb.length() - 1); } static long toNo(String[] ip) { long result = 0; for (int i = 0; i < Integer.SIZE; i += Byte.SIZE) { result <<= 8; result |= Integer.parseInt(ip[i >> 3]); } return result; } }