记录编号 7932 评测结果 AAAAAAAAAA
题目名称 IP网络管理员 最终得分 100
用户昵称 Gravatar苏轼 是否通过 通过
代码语言 Pascal 运行时间 0.056 s
提交时间 2008-11-12 15:25:59 内存使用 0.12 MiB
显示代码纯文本
program cch(input,output);
var
 i,n,k,j,q,k1,tmp,ans,key,code,ans1:integer;
 a:array[1..1000,1..4] of integer;
 s,s1:string;
 flag:boolean;
begin
 assign(input,'networkip.in');
 assign(output,'networkip.out');
 reset(input);
 rewrite(output);
 readln(n);

 for i:=1 to n do
  begin
   readln(s);
   s:=s+'.';
   for k:=1 to 4 do
    begin
     s1:=copy(s,1,pos('.',s)-1);
     val(s1,a[i,k],code);
     delete(s,1,pos('.',s));
    end;
  end;

 for i:=1 to 4 do
  begin
   flag:=true; tmp:=a[1,i];
   for j:=2 to n do
    if tmp<>a[j,i] then
     begin
      flag:=false;
      break;
     end;
   if not flag then
    begin
     key:=i;
     break;
    end;
  end;
 if key>0 then
 for k:=8 downto 1 do
  begin
   tmp:=a[1,key] shr (k-1) and 1;
   for j:=2 to n do
    begin
     k1:=a[j,key] shr (k-1) and 1;
     if tmp<>k1 then
      begin
       ans:=a[1,key] or (1 shl k-1);
       ans:=ans xor (1 shl k-1);
       for i:=1 to key-1 do
        write(a[1,i],'.');
       write(ans);
       for i:=key+1 to 4 do
        write('.',0);
       writeln;
       for i:=1 to key-1 do
        write(255,'.');
       ans1:=0;
       for i:=8 downto k+1 do
        begin
         tmp:=1;
         for q:=1 to i-1 do tmp:=tmp*2;
         ans1:=ans1+tmp;
        end;
       write(ans1);
       for i:=key+1 to 4 do
        write('.',0);
       close(input); close(output);
       halt;
      end;
    end;
  end;
 for i:=1 to 3 do write(a[1,i],'.');
 writeln(a[1,4]);
 write('255.255.255.255');
 close(input); close(output);
end.