题目:http://poj.org/problem?id=2799
思路:找出IP的最长公共前缀即最小网络,长度即子网掩码全1的长度
#include <cstdio>
#define MAX 1005
int main()
{
unsigned n, i, a, b, c, d, ip, net;
int len;
while(scanf("%u", &n) == 1){
scanf("%u.%u.%u.%u", &a, &b, &c, &d);
net = a << 24 | b << 16 | c << 8 | d;
len = 32;
for(i = 1; i < n; ++i){
scanf("%u.%u.%u.%u", &a, &b, &c, &d);
ip = a << 24 | b << 16 | c << 8 | d;
//find longest common prefix between ip and net
int b = 31;
for(; b &